1

I want to know to which UTM zone belong a shapefile.

With GeoPandas I can read a shapefile and know its EPSG code:

import geopandas as gpd dataframe = gpd.read_file('shapefile.shp') print(dataframe.crs)

{'init': 'epsg:32616'}

Is there anyway to get the UTM zone with GeoPandas or to transform the EPSG code to UTM zone? for example epsg:32616 would be the UTM zone 16 N.

Vince
  • 20,017
  • 15
  • 45
  • 64
David1212k
  • 355
  • 1
  • 11
  • related https://gis.stackexchange.com/questions/60371/gdal-python-how-do-i-get-coordinate-system-name-from-spatialreference – nmtoken Sep 03 '19 at 13:54
  • Not sure if it's currently possible see https://github.com/geopandas/geopandas/issues/543 – nmtoken Sep 03 '19 at 14:03

1 Answers1

1

Looking at an open issue #543 on geopandas GitHub, it appears that what you want to do is not yet possible.

As you have fiona then you can use:

import fiona


source_crs_wkt = fiona.open(shapedata).meta['crs_wkt']
print(source_crs_wkt)

To give for example from an EPSG:4326 projected shapefile:

GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]

and if you have osr

import osr


srs = osr.SpatialReference(wkt=source_crs_wkt)
print(srs.GetAttrValue('geogcs'))

will give:

WGS 84
nmtoken
  • 13,355
  • 5
  • 38
  • 87