Transforming CRS to UTM

I am trying to transform CRS to UTM using a GeoJSON file. This is what I tried:

from sentinelhub import CRS
country_crs = CRS.UTM_32N
country = country.to_crs(crs={'init':CRS.ogc_string(country_crs)})
country.plot()
country.crs

But this code results in a completly wrong transformation followed by a warning message:

C:\Users\ASUS\Anaconda3\envs\ASV\lib\site-packages\pyproj\crs\crs.py:53: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  return _prepare_from_string(" ".join(pjargs))

trying this:

country = country.to_crs("EPSG:22391")
country.plot()
country.crs

resulted in the following: (negative values in the Y-axis):

Using latest sentinelhub and geopandas, try

country = country.to_crs(country_crs.pyproj_crs())
1 Like

I tried this one too but resulted in:

Sorry, but I do not know what is the issue here. It seems the transformation now works.

Hello,

Looking at the image you show in your last post, could you please explain what coordinates you are expecting from the reprojection to UTM?

In the image you have posted the x-coordinates are between ~400000 and 700000 m, and your y-coordinates are between ~3400000 and 4200000 m (note that the values on your graph are multiplied by 1e6). These values do correspond to Tunesia in the UTM 32N projection which is in meters: see epsg.io, so it looks correct to me.

2 Likes

I am not sure either, but according to this website : Spatial Reference the EPSG of Tunisia is 22391 and in here I got 32632

In your first example, the negative values are correct because the projection of North Tunisia (EPSG 22391) covers only the Northern part of the Country. So the reference point for the y-coordinates (0 m) is just south of Medinine (مدنين).

Did you get the result in EPSG:32632 that we can see in the cell [4] of your notebook after having specified EPSG:22391? That would be strange…

1 Like

No I got 32632 when I tried this:

country = country.to_crs(country_crs.pyproj_crs())

Thanks a lot !

Sentinel-2 data (original scenes) are in UTM coordinate reference system. Tunisia falls into the 32N zone (EPSG:32632), so the result is correct - the whole point (see your first point) was to transform the shape into correct UTM zone.

Ok. Thanks a lot for your help!