Extract EPSG code from GeoDataFrame.crs result

Viewed 405

Let's say I have a GeoDataFrame with a CRS set.

gdf.crs

gives me

<Projected CRS: EPSG:25833>
Name: ETRS89 / UTM zone 33N
Axis Info [cartesian]:
- [east]: Easting (metre)
- [north]: Northing (metre)
Area of Use:
- undefined
Coordinate Operation:
- name: UTM zone 33N
- method: Transverse Mercator
Datum: European Terrestrial Reference System 1989
- Ellipsoid: GRS 1980
- Prime Meridian: Greenwich

This is of type <class 'pyproj.crs.crs.CRS'>. Is there a way to extract the EPSG Code from this, thus 25833?

1 Answers

.crs returns a pyroj.CRS object. This should get you the EPSG code from the object:

gdf.crs.to_epsg()

pyproj docs

Related