Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with some CRS transformations #261

Open
glaroc opened this issue Nov 5, 2024 · 1 comment
Open

Problem with some CRS transformations #261

glaroc opened this issue Nov 5, 2024 · 1 comment

Comments

@glaroc
Copy link

glaroc commented Nov 5, 2024

We have a problem with some collections in our STAC catalog that are in less common reference systems.

For example, this collection has one item in epsg:3347, and a simple stack() produces an error, even when not changing the CRS from the input source.

import pystac_client
import stackstac

catalog = pystac_client.Client.open("https://io.biodiversite-quebec.ca/stac")

items = catalog.search(
    collections=["pither_functional_connectivity"]
).item_collection()
stack = stackstac.stack(items, resolution=300, epsg=3347, bounds=(7227806, 1242748, 7602593, 1529390))

Here is the error

Traceback (most recent call last):
  File "/home/glaroc/.vscode/extensions/ms-python.python-2024.18.0-linux-x64/python_files/python_server.py", line 130, in exec_user_input
    retval = callable_(user_input, user_globals)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 1, in <module>
  File "/home/glaroc/.local/lib/python3.12/site-packages/stackstac/stack.py", line 290, in stack
    asset_table, spec, asset_ids, plain_items = prepare_items(
                                                ^^^^^^^^^^^^^^
  File "/home/glaroc/.local/lib/python3.12/site-packages/stackstac/prepare.py", line 260, in prepare_items
    asset_bbox_proj = geom_utils.reproject_bounds(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/glaroc/.local/lib/python3.12/site-packages/stackstac/geom_utils.py", line 52, in reproject_bounds
    xs_proj, ys_proj = transformer.transform(xs, ys, errcheck=True)  # TODO handle error
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/pyproj/transformer.py", line 843, in transform
    self._transformer._transform(
  File "pyproj/_transformer.pyx", line 726, in pyproj._transformer._Transformer._transform
pyproj.exceptions.ProjError: transform error: Invalid coordinate: (Internal Proj Error: lcc: Invalid latitude)

Any help or guidance as to why this could be happening would be appreciated. We don't have this problem with other collections. Happens with stackstac==0.5.1 and pyproj==3.6.1.

@glaroc
Copy link
Author

glaroc commented Nov 5, 2024

This is probably an issue with the bbox in our STAC catalog being in the CRS of the item, and not in 4326. Will revisit once corrected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant