dask_geopandas.GeoSeries.clip

Contents

dask_geopandas.GeoSeries.clip#

GeoSeries.clip(mask, keep_geom_type=False)#

Clip points, lines, or polygon geometries to the mask extent.

This docstring was copied from geopandas.geodataframe.GeoDataFrame.clip.

Some inconsistencies with the Dask version may exist.

Both layers must be in the same Coordinate Reference System (CRS). The GeoDataFrame will be clipped to the full extent of the mask object.

If there are multiple polygons in mask, data from the GeoDataFrame will be clipped to the total boundary of all polygons in mask.

Parameters:
maskGeoDataFrame, GeoSeries, (Multi)Polygon, list-like

Polygon vector layer used to clip the GeoDataFrame. The mask’s geometry is dissolved into one geometric feature and intersected with GeoDataFrame. If the mask is list-like with four elements (minx, miny, maxx, maxy), clip will use a faster rectangle clipping (clip_by_rect()), possibly leading to slightly different results.

keep_geom_typeboolean, default False

If True, return only geometries of original type in case of intersection resulting in multiple geometry types or GeometryCollections. If False, return all resulting geometries (potentially mixed types).

sortboolean, default False (Not supported in Dask)

If True, the order of rows in the clipped GeoDataFrame will be preserved at small performance cost. If False the order of rows in the clipped GeoDataFrame will be random.

Returns:
GeoDataFrame

Vector data (points, lines, polygons) from the GeoDataFrame clipped to polygon boundary from mask.

See also

clip

equivalent top-level function

Examples

Clip points (grocery stores) with polygons (the Near West Side community):

>>> import geodatasets  
>>> chicago = geopandas.read_file(  
...     geodatasets.get_path("geoda.chicago_health")
... )
>>> near_west_side = chicago[chicago["community"] == "NEAR WEST SIDE"]  
>>> groceries = geopandas.read_file(  
...     geodatasets.get_path("geoda.groceries")
... ).to_crs(chicago.crs)
>>> groceries.shape  
(148, 8)
>>> nws_groceries = groceries.clip(near_west_side)  
>>> nws_groceries.shape  
(7, 8)