geopandas / pyogrio

Vectorized vector I/O using OGR
https://pyogrio.readthedocs.io
MIT License
272 stars 22 forks source link

[Request] Add support for "Measured 3D LineString" #333

Open DeflateAwning opened 9 months ago

DeflateAwning commented 9 months ago

When I import a dataset with a "Measured 3D LineString" geometry, I receive a UserWarning: Measured (M) geometry types are not supported. Original type 'Measured 3D LineString' is converted to 'LineString Z'.

I would like to request that support for Measured 3D LineStrings be added, as they are useful for a variety of applications.

The userwarning is generated in pyogrio/raw.py:194

An example dataset (albeit a rather large one: 70 MB and 112,995 rows) is here: https://static.aer.ca/prd/documents/sts/st37/Township_1-25.zip (specifically, the ST37_WG_GCS_NAD83_TWP_01_25.shp shapefile).

brendan-ward commented 9 months ago

As I recall, up until GEOS 3.12, GEOS did not support ZM coordinates, so we had no way to do anything with them and opted to force them to drop their M value when reading using GDAL. In order for us to use in a meaningful way, ZM support needs to be available within Shapely, and this functionality would be limited to GEOS >= 3.12. We could probably add a parameter to allow return of ZM WKB instead of forcing the M value to be dropped, but that doesn't seem as useful on its own.

Related: https://github.com/shapely/shapely/issues/1648, https://github.com/shapely/shapely/pull/1808

DeflateAwning commented 9 months ago

The use case for me is just doing basic pandas transformations using geopandas, which depends on this lib, and then exporting them as WKT/WKB afterwards.

brendan-ward commented 9 months ago

In order to use in GeoPandas, we'd need to be able to handle the geometries in Shapely first. However, if you are only doing operations in Pandas (nothing involving the geometry), then it would be possible (once we've enabled it at a lower level) to use the pyogrio.raw.read interface and use the results to construct a Pandas DataFrame that has a WKB column.