hydromt.gis_utils.nearest_merge#
- hydromt.gis_utils.nearest_merge(gdf1: ~geopandas.geodataframe.GeoDataFrame, gdf2: ~geopandas.geodataframe.GeoDataFrame, columns: list | None = None, max_dist: float | None = None, overwrite: bool = False, inplace: bool = False, logger=<Logger hydromt.gis_utils (WARNING)>) GeoDataFrame [source]#
Merge attributes of gdf2 with the nearest feature of gdf1.
Output is optionally bounded by a maximumum distance max_dist. Unless overwrite = True, gdf2 values are only merged where gdf1 has missing values.
- Parameters:
gdf1 (
geopandas.GeoDataFrame
) – Source gdf1 and destination gdf2 geometries.gdf2 (
geopandas.GeoDataFrame
) – Source gdf1 and destination gdf2 geometries.columns (
list
ofstr
, optional) – Names of columns in gdf2 to merge, by default Nonemax_dist (
float
, optional) – Maximum distance threshold for merge, by default None, i.e.: no threshold.overwrite (
bool
, optional) – If False (default) gdf2 values are only merged where gdf1 has missing values, i.e. NaN values for existing columns or missing columns.inplace (
bool,
) – If True, apply the merge to gdf1, otherwise return a new object.logger – The logger to use.
- Returns:
Merged GeoDataFrames
- Return type:
gpd.GeoDataFrame