pythongeopandaspyproj

Extract EPSG code from GeoDataFrame.crs result


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?


Solution

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

    gdf.crs.to_epsg()
    

    pyproj docs