geopandas.GeoDataFrame.set_geometry

GeoDataFrame.set_geometry(self, col, drop=False, inplace=False, crs=None)

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.

Parameters
colcolumn label or array
dropboolean, default True

Delete column to be used as the new geometry

inplaceboolean, default False

Modify the GeoDataFrame in place (do not create a new object)

crspyproj.CRS, optional

Coordinate system to use. The value can be anything accepted by pyproj.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.

Returns
GeoDataFrame

Examples

>>> df1 = df.set_geometry([Point(0,0), Point(1,1), Point(2,2)])
>>> df2 = df.set_geometry('geom1')