Nothing Special   »   [go: up one dir, main page]

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

transform_geom (warp) fails for shape crossing the antimeridian on MacOS #3110

Open
johnnylarner opened this issue Jun 28, 2024 · 2 comments

Comments

@johnnylarner
Copy link
johnnylarner commented Jun 28, 2024

Expected behavior and actual behavior.

When I project a shape that crosses the AML, I expect it to be represented as a Multipolygon, where each polygon is the space either side of the AML.

Instead I get a single Polygon.

When I run the same code on an emulated x86 architecture, I get the expected output (a Multipolygon)

MacOS
CRS agnostic shape: POLYGON ((687070 6206080, 687070 7100460, 312930 7100460, 312930 6206080, 687070 6206080))

Reprojected Shape: {'type': 'Polygon', 'coordinates': [[(179.99715482523962, 55.9635596501913), (-179.17629842154972, 63.980557342365294), (173.1762984215497, 63.980557342365294), (174.00284517476035, 55.9635596501913), (179.99715482523962, 55.9635596501913)]]}
x86
CRS agnostic shape: POLYGON ((687070 6206080, 687070 7100460, 312930 7100460, 312930 6206080, 687070 6206080))

Reprojected Shape: {'type': 'MultiPolygon', 'coordinates': [[[(179.99715482523962, 55.9635596501913), (174.00284517476035, 55.9635596501913), (173.1762984215497, 63.980557342365294), (180.0, 63.999936685262035), (180.0, 56.000297742376915), (179.99715482523962, 55.9635596501913)]], [[(-179.17629842154972, 63.980557342365294), (-180.0, 56.00029776709144), (-180.0, 63.99993668522069), (-179.17629842154972, 63.980557342365294)]]]}

Steps to reproduce the problem.

  1. Clone this repo
  2. Run pdm install to setup the env
  3. Run make test-macos to see the buggy stuff
  4. Run make test-x86 to see the expected behaviour

To see the runtime envs, run: make info

Note I've tested this on a colleague's x86 machine with matching GDAL versions and the issue persists. Other colleagues on MacOS face the same problems

Environment Information

rasterio info:
  rasterio: 1.3.10
      GDAL: 3.8.4
      PROJ: 9.3.1
      GEOS: 0.0.0

System:
    python: 3.12.4 (main, Jun  6 2024, 18:26:44) [Clang 15.0.0 (clang-1500.3.9.4)]
   machine: macOS-14.0-arm64-arm-64bit

Installation Method

pip via pdm

@johnnylarner
Copy link
Author

We encountered this problem when using this method from the stactools lib, which uses the linked reproducible code under the hood here.

@johnnylarner johnnylarner changed the title Geometry projection fails for shape crossing the antimeridian on MacOS transform_geom (warp) fails for shape crossing the antimeridian on MacOS Jun 28, 2024
@sgillies
Copy link
Member
sgillies commented Aug 2, 2024

@johnnylarner thanks for the report! I need a more simple reproducer. Like a single polygon and an invocation of transform_geom() (see https://github.com/rasterio/rasterio/blob/main/tests/test_warp.py#L1170) that doesn't result in a split when it should.

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

No branches or pull requests

2 participants