opendatacube / odc-geo

GeoBox and geometry utilities extracted from datacube-core
https://odc-geo.readthedocs.io/en/latest/
Apache License 2.0
80 stars 12 forks source link

transform_to_crs(crs) unable to handle polygons with z dimension (3D polygons) #173

Open LaurenSchenk1 opened 1 month ago

LaurenSchenk1 commented 1 month ago

Hi! I tried running a polygon with the WIT notebook and the error message "TypeError: CRS.transformer_to_crs..result() takes 2 positional arguments but 3 were given" appeared.

I removed the "Z"/elevation values/dimension from the shapefile and it seems to work. However, this required me opening the shapefile in ArcGIS and manually removing them.

After speaking with Ariana, it seems transform_to_crs(crs) in both odc.geo.geometry and datacube.utils.geometry cannot handle having 3 values even though shapely can handle the optional Z values.

If it's not possible for this function to handle the 3 values, can the error message be updated to make it clearer that it's the 3 dimensions (presence of "Z" coordinates) which is causing the issue.

Hopefully this makes sense.

SpacemanPaul commented 1 month ago

Shapely knows nothing about CRS's and doesn't handle coordinate transforms, so it's about what PyProj can support rather than Shapely. However, PyProj DOES support 3D coordinate transforms, so this should be doable, although I'm not sure how major the required changes would be. (digging into the source code a bit, pretty major. the 2D assumption goes pretty deep)