clip_to_boundary#

caf.cvt.data_cleaning.clip_to_boundary(gdf, boundary)[source]#

Clip a GeoDataFrame to a specified spatial boundary.

This function re-projects the boundary to match the CRS of the input GeoDataFrame and then clips the geometries in the GeoDataFrame so that only features within the boundary are retained.

Parameters:
  • gdf (geopandas.GeoDataFrame) – The input GeoDataFrame containing geometries to be clipped.

  • boundary (geopandas.GeoDataFrame) – The GeoDataFrame representing the clipping boundary.

Returns:

A new GeoDataFrame containing only the geometries from ‘gdf’ that fall within the specified boundary.

Return type:

geopandas.GeoDataFrame