In data assimilation applications using ensemble Kalman filter methods, localization is necessary to make the method work with high-dimensional geophysical models. For ensemble square-root Kalman filters, domain localization (DL) and observation localization (OL) are commonly used. Depending on the localization method, one has to choose appropriate values for the localization parameters, such as the localization length and the weight function. Although frequently used, the properties of the localization techniques are not fully investigated. Thus, up to now an optimal choice for these parameters is a priori unknown and they are generally found by expensive numerical experiments. In this study, the relationship between the localization length and the ensemble size in DL and OL is studied using twin experiments with the Lorenz-96 model and a 2-dimensional shallow water model. For both models, it is found that the optimal localization length for DL and OL depends linearly on an effective local observation dimension that is given by the sum of the observation weights. In the experiments no influence of the model dynamics on the optimal localization length was observed. The effective observation dimension defines the degrees of freedom that are required for assimilating observations, while the ensemble size defines the available degrees of freedom. Setting the localization radius such that the effective local observation dimension equals the ensemble size yields an adaptive localization radius. Its performance is tested using a global ocean model. The experiments show that the analysis quality using the adaptive localization is similar to the analysis quality of an optimally tuned constant localization radius.