> ## 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.set_geometry

> Set the GeoDataFrame geometry using either an existing column or the specified input.

Set the GeoDataFrame geometry using either an existing column or
the specified input. By default yields a new object.

The original geometry column is replaced with the input.

## Signature

```python theme={"system"}
set_geometry(
    col,
    drop: bool | None = None,
    inplace: bool = False,
    crs: Any | None = None,
) -> GeoDataFrame | None
```

## Parameters

<ParamField path="col" type="column label or array-like" required>
  An existing column name or values to set as the new geometry column.
  If values (array-like, (Geo)Series) are passed, then if they are named
  (Series) the new geometry column will have the corresponding name,
  otherwise the existing geometry column will be replaced. If there is
  no existing geometry column, the new geometry column will use the
  default name "geometry".
</ParamField>

<ParamField path="drop" type="bool | None" default="None">
  When specifying a named Series or an existing column name for `col`,
  controls if the previous geometry column should be dropped from the
  result. The default of False keeps both the old and new geometry column.

  <Warning>
    Deprecated since version 1.0.0.
  </Warning>
</ParamField>

<ParamField path="inplace" type="bool" default="False">
  Modify the GeoDataFrame in place (do not create a new object)
</ParamField>

<ParamField path="crs" type="Any | None" default="None">
  Coordinate system to use. The value can be anything accepted
  by `pyproj.CRS.from_user_input() <pyproj.crs.CRS.from_user_input>`,
  such as an authority string (eg "EPSG:4326") or a WKT string.
  If passed, overrides both DataFrame and col's crs.
  Otherwise, tries to get crs from passed col values or DataFrame.
</ParamField>

## Returns

<ResponseField name="return" type="GeoDataFrame" />

**See also**

* `GeoDataFrame.rename_geometry`: rename an active geometry column

## Examples

```python theme={"system"}
>>> from sedona.spark.geopandas import GeoDataFrame
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = GeoDataFrame(d, crs="EPSG:4326")
>>> gdf
    col1     geometry
0  name1  POINT (1 2)
1  name2  POINT (2 1)
```

Passing an array:

```python theme={"system"}
>>> df1 = gdf.set_geometry([Point(0,0), Point(1,1)])
>>> df1
    col1     geometry
0  name1  POINT (0 0)
1  name2  POINT (1 1)
```

Using existing column:

```python theme={"system"}
>>> gdf["buffered"] = gdf.buffer(2)
>>> df2 = gdf.set_geometry("buffered")
>>> df2.geometry
0    POLYGON ((3 2, 2.99037 1.80397, 2.96157 1.6098...
1    POLYGON ((4 1, 3.99037 0.80397, 3.96157 0.6098...
Name: buffered, dtype: geometry
```


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