pylusat.interpolate module
- pylusat.interpolate.idw(input_gdf, value_gdf, value_clm, power=2, n_neighbor=12, search_radius=None, leafsize=14, min_dist=1e-12, dtype=<class 'float'>)
Interpolation using inverse distance weighting (IDW).
This function implements an IDW interpolation <https://en.wikipedia.org/wiki/Inverse_distance_weighting>. The power parameter dictates how fast the influence to a given location by its nearby objects decays. idw_cv, a k-fold cross validation method is offered to determine the most appropriate value of the power parameter.
- Parameters:
input_gdf (geopandas.GeoDataFrame) – Input GeoDataFrame. Centroids of the input geometries are used.
value_gdf (geopandas.GeoDataFrame) – GeoDataFrame containing the values needed to be interpolated.
value_clm (str) – The name of the column that holds the values in value_gdf.
power (int or float, optional) – The power parameter in IDW.
n_neighbor (int, optional) – Number of neighborhoods used for IDW.
search_radius (float, optional) – Maximum distance used to find neighbors. If not provided, the function will search for all neighbors specified by n_neighbors.
leafsize (positive int, optional) – The number of points at which the algorithm switches over to brute-force. Default: 14. See scipy.spatial.cKDTree for further information.
min_dist (float, optional) – The distance below which the interpolated value will be set to equal to the value of its closest neighbor.
dtype (str or numpy.dtype, optional) – Use a np.dtype or Python type to cast the interpolated values to the desired type.
- Returns:
output_sr – pandas Series that contains the interpolated values for all feature in the input_gdf.
- Return type:
Examples
Interpolate Enrollment values in Schools GeoDataFrame to the second power with 12 neighborhoods.
>>> pylusat.interpolate.idw(acs2016_gdf, schools_gdf, 'ENROLLMENT', power=2.00, n_neighbor=12) 0 26.407251 1 137.199332 2 205.822340 3 231.137558 4 158.283367 ... 150 239.502760 151 404.536623 152 233.601194 153 228.459787 154 490.956496