POINT M parsed as POINT Z
See original GitHub issueI’m writing a service that is an interface to pyproj, currently using Shapely to handle WKT de/serialisation. I need to support Z
, M
and ZM
geometry types, e.g. POINT Z
, POINT M
and POINT ZM
, because the service is expected to handle vertical datum transformations, and time-dependent datum shifts, so both Z (verical) and M (time) are important pieces of information.
I understand that Shapely does not support M
and in fact will silently drop it and therefore does not produce M
output; this is fine for my use-case. What I find particularly difficult to handle is that POINT M
gets re-interpreted as POINT Z
, so it’s not just a matter of the measure being dropped, but actually re-interpreted as a vertical coordinate that is not present in the input.
Expected behavior and actual behavior
Expected
My ideal result is that M values are retained:
from shapely import wkt
g = wkt.loads('POINT M (0 0 5)')
g.wkt
# 'POINT M (0 0 5)'
Failing that, anticipating that’s a lot of work to implement, I’d be happy with the following, since it’s merely lossy rather than inventing new information.
from shapely import wkt
g = wkt.loads('POINT M (0 0 5)')
g.wkt
# 'POINT (0 0)'
Actual
from shapely import wkt
g = wkt.loads('POINT M (0 0 5)')
g.wkt
# 'POINT Z (0 0 5)'
Steps to reproduce the problem.
See above. These examples are for POINT, but the problem is present for other geometry types too.
Operating system
Docker (Debian bullseye-slim)
Shapely version and provenance
1.7.0 installed from PyPI using pip
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Unrelated to the actual issue, but just want to counter-balance this statement a bit 😉 It’s not because they didn’t fix the WKT parsing issue, that GEOS is moving only slowly. There have been many exciting new features and improvements in the last releases (eg robust overlays with big speed-ups and fixed precision).
(but, it’s probably correct to say that there isn’t much development around geometries with “M” coordinates, and which is generally not well supported by GEOS. So if you need those features, looking at GDAL might be the better option)
This is fixed on GEOS main branch:
(we don’t yet have the APIs to access that M value (-> https://github.com/shapely/shapely/issues/1648), but at least the parsing works correctly)