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:

+init=epsg:4326
{‘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?

2 Likes

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
sentinelhub.CRS(lng_lat_def)

# the following raises an error
sentinelhub.CRS(lat_lng_def)

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!

Mike

Hi @maleksandrov,

Can you help me here. I am facing with the saem issue whe I try creating the bbox splitter

bbox_splitter = UtmZoneSplitter([country_shape], country.crs, 5000)

When I try to run this command I come up with this 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

Can you help me resolve this issue?

Hi @Vikrutas55,

There are 2 quick fix options:

  • replace country.crs with sentinelhub.CRS.WGS84,
  • upgrade sentinelhub package to version 3.1.0, where this will only show a warning instead of raising an error.

Also check my answer above for an explanation of the issue.

1 Like

When I tried this I am getting the following Error.
ValueError: The list of shapes must contain shapes of types <class ‘type’>, <class ‘type’> or subtype of <class ‘abc.ABCMeta’>

Thanks a lot!!! @maleksandrov.
It is working fine.