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.

2

1 Answer 1

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
3
  • WGS 84 is not the information that I wanted but I have checked that at least with my shapefile it also prints the UTM zone: 'PROJCS["WGS 84 / UTM zone 16N", ... '.
    – David1212k
    Sep 3, 2019 at 15:37
  • what about print(srs.GetAttrValue('projcs'))
    – nmtoken
    Sep 3, 2019 at 16:00
  • Yes with that I get 'WGS 84 / UTM zone 16N' which is the information I need.
    – David1212k
    Sep 3, 2019 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.