I have a shapefile which I read with GeoPandas, this shapefile has lat/long coordinates and I want to transform it to UTM coordinates. I tried this:

shapefile = gpd.read_file('example.shp') #CRS = epsg:4326
shapefile.to_crs("+proj=utm +ellps=WGS84 +datum=WGS84 +units=m +no_defs",inplace=True)

But it doesn't transform my coordinates correctly. I think it is because I have to explicitly put in the code the UTM zone with the number and letter which can vary depending on the shapefile I read.

So for calculating the letter and number I tried this:

import utm
utmZones = set()
for p in shapefile.geometry:

{(20, 'H'), (20, 'J'), (21, 'H')}

If the polygons fall in three different adjacent UTM zones is there any problem if I choose the UTM zone which is in the middle or should I create three different shapefiles one for each UTM zone?

  • Could it be that your input shape file spans a great area, so that the geometries would actually fall in multiple utm zones?
    – Johan
    Commented Sep 26, 2019 at 9:37
  • The extent of the shapefile is: -65.7119415675062299,-37.0586312600577870 : -59.4019001867139096,-28.3061813103935407 It could be, but it would be strange. How can I check it?
    – David1212k
    Commented Sep 26, 2019 at 9:57
  • You can for example download the utm zones grid and open that and your shp in a GIS to see which zones intersect with your shapefile
    – Johan
    Commented Sep 26, 2019 at 10:33
  • 1
    UTM Zones are six degrees wide. You can determine the zone by adding 183 degrees to longitude, dividing by 6 and rounding (or adding 186 and truncating after division). Data should not be permitted to exceed 3-4 degrees into neighboring zones; if it does, UTM is the wrong projection, and you should use a conic (e.g., Albers Equal Area) instead.
    – Vince
    Commented Sep 26, 2019 at 11:19
  • Is the data in Argentina or Antarctica/south Atlantic? If the former, it's in zones 20 and 21 south (mostly 20); if the latter, yes, it's in zones 24 - 26 south (mostly 25) so you should add a +south to the PROJ string besides the zone number.
    – mkennedy
    Commented Sep 26, 2019 at 16:44

1 Answer 1


"choose the UTM zone which is in the middle or should I create three different shapefiles one for each UTM zone?". It depends on your demands of accuracy.

The further from the center meridian you move in the more distorted your data will become. See: https://gisgeography.com/utm-universal-transverse-mercator-projection/

You can use .estimate_utm_crs to find a suitable utm crs, reproject and save to file.

I have a data frame with three countries in it: Spain, Italy and Turkey. They are all in different UTM zones:

import geopandas as gpd
import os
df = gpd.read_file(r"/home/bera/Desktop/GIStest/spain_italy_turkey.geojson")

#I have a unique ID column called NAME
for name, subframe in df.groupby("NAME"):
    print(subframe.estimate_utm_crs(datum_name='WGS 84')) #Find its utm zone
    # Italy
    # EPSG:32633
    # Spain
    # EPSG:32629
    # Turkey
    # EPSG:32636
#For each country, create a new shapefile
out_folder = r"/home/bera/Desktop/GIStest/utm_converted/"
for name, subframe in df.groupby("NAME"):
    subframe = subframe.to_crs(subframe.estimate_utm_crs(datum_name='WGS 84')) #Reproject
    #Save to file
    out_file = os.path.join(out_folder, f"{name}_reprojected.shp")

enter image description here

Your Answer

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

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