> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GeoDataFrame.clip

> Clip geometries to a polygonal or rectangular mask.

Clip geometries to a polygonal or rectangular mask.

Distributed `GeoSeries` and `GeoDataFrame` masks are dissolved on
the cluster before clipping. A four-value list-like mask is interpreted
as `(minx, miny, maxx, maxy)`. Both distributed layers should use the
same Coordinate Reference System (CRS); a mismatch emits a warning.

## Signature

```python theme={"system"}
clip(mask, keep_geom_type=False, sort=False)
```

## Parameters

<ParamField path="mask" type="GeoDataFrame, GeoSeries, Polygon, MultiPolygon, or list-like" required>
  Polygonal mask, or four rectangle bounds. Distributed masks are
  dissolved into one geometry using `ST_Union_Aggr`.
</ParamField>

<ParamField path="keep_geom_type" type="bool" default="False">
  If True, retain only the input geometry family when clipping
  creates lower-dimensional geometries.
</ParamField>

<ParamField path="sort" type="bool" default="False">
  If True, return matching rows in their original positional order.
</ParamField>

## Returns

<ResponseField name="return" type="GeoDataFrame or GeoSeries">
  Clipped data of the same type as the caller. Index values,
  non-geometry columns, active geometry, CRS, and SRID are preserved.
</ResponseField>

**See also**

* `GeoSeries.clip_by_rect`
* `geopandas.clip`

<Note>
  Sedona does not expose a separate fast `ClipByBox` operation.
  Four-value rectangle masks therefore use native `ST_MakeEnvelope`
  and `ST_Intersection`. Boundary-only intersections can consequently
  differ from GeoPandas' fast, possibly dirty rectangle path.
</Note>

## Examples

```python theme={"system"}
>>> from sedona.spark.geopandas import GeoDataFrame
>>> from shapely.geometry import LineString, Point, box
>>> gdf = GeoDataFrame(
...     {
...         "name": ["line", "point"],
...         "geometry": [
...             LineString([(0, 0), (2, 2)]),
...             Point(3, 3),
...         ],
...     }
... )
>>> gdf.clip(box(0, 0, 1, 1))
   name               geometry
0  line  LINESTRING (0 0, 1 1)
```

Rectangle bounds can be supplied directly:

```python theme={"system"}
>>> gdf.geometry.clip((0, 0, 1, 1))
0    LINESTRING (0 0, 1 1)
Name: geometry, dtype: geometry
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.