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:
utmZones.add(utm.from_latlon(p.centroid.y,p.centroid.x)[2:4])
print(utmZones)
{(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?