WGS 84 and pyproj (python eo-learn workflow)

Hello all,

Using a shape file for my area of interest, I am having trouble moving forward with the following error:

ValueError: sentinelhub-py supports only WGS 84 coordinate reference system with coordinate order lng-lat. However pyproj.CRS(4326) has coordinate order lat-lng.

I used the fiona.to_string command and get:

{‘datum’: ‘WGS84’, ‘ellps’: ‘WGS84’, ‘no_defs’: True, ‘proj’: ‘longlat’}

. Does sentinelhub-py automatically see EPSG=4326 and assume lat-long?

Anyone else have this problem?

Hi @mhylind,

Here is a snippet that demonstrates why the issue happens:

import pyproj
import sentinelhub

lat_lng_def = pyproj.CRS(4326)
lng_lat_def = sentinelhub.CRS.WGS84.pyproj_crs()

# the following works

# the following raises an error

Basically, in sentinelhub-py we use lng-lat coordinate order and in pyproj by default lat-lng order is used. Therefore sentinelhub-py raises an error whenever pyproj.CRS(4326) would be converted in sentinelhub.CRS.WGS84 to prevent potential mismatches in coordinate order.

I don’t know how you pass a CRS parameter to sentinelhub-py but I suggest that instead of pyproj.CRS(4326) you simply use sentinelhub.CRS.WGS84.

In the future, we intend to change the error into a warning. That is because many packages (e.g. geopandas) use pyproj.CRS(4326) but internally interpret coordinates with order lng-lat. Therefore, in such cases a conversion could still be ok.

Thanks for the clarification and quick response…that address the problem perfectly!