[gdal-dev] Ogrinfo, WKT and geometries with Z

Even Rouault even.rouault at spatialys.com
Thu Feb 11 02:15:33 PST 2016


Le jeudi 11 février 2016 10:53:06, Jukka Rahkonen a écrit :
> Hi,
> 
> Ogrinfo is printing the WKT of XYZ geometries this way:
> 
> ogrinfo polygonz.gpkg -al
> INFO: Open of `polygonz.gpkg'
>       using driver `GPKG' successful.
> 
> Layer name: polygonz
> Geometry: Unknown (any)
> Feature Count: 1
> Extent: (340.000000, 420.000000) - (560.000000, 580.000000)
> Layer SRS WKT:
> (unknown)
> FID Column = fid
> Geometry Column = geom
> OGRFeature(polygonz):1
>   POLYGON ((340 580 1,560 580 2,560 420 3,340 580 1))
> 
> 
> In "OpenGIS® Implementation Standard for Geographic information - Simple
> feature access - Part 1: Common architecture" POINT is defined as 2
> dimensional. Wouldn't the right WKT be
>   POLYGON Z ((340 580 1,560 580 2,560 420 3,340 580 1)) ?
> 
> I have tested that some software like OpenJUMP and PostGIS do accept
> POLYGON with 3 coordinates while some other like Spatialite do not.
> Because Ari is now working with XYZ(M) code would this also be worth a
> review?

Jukka,

The OGRGeometry class can, since GDAL 2.0, depending on a parameter, export 
WKT as the "traditional" form GDAL has always used without Z suffix  (and for M 
/ ZM geometries, it drop the M component), or to be ISO compliant with Z/M/ZM 
suffix.

In C, 
OGR_G_ExportToWkt(): traditional WKT
OGR_G_ExportToIsoWkt(): ISO WKT


>>> print ogr.CreateGeometryFromWkt('POINT Z (1 2 3)').ExportToWkt()
POINT (1 2 3)
>>> print ogr.CreateGeometryFromWkt('POINT M (1 2 3)').ExportToWkt()
POINT (1 2)
>>> print ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)').ExportToWkt()
POINT (1 2 3)

>>> print ogr.CreateGeometryFromWkt('POINT Z (1 2 3)').ExportToIsoWkt()
POINT Z (1 2 3)
>>> print ogr.CreateGeometryFromWkt('POINT M (1 2 3)').ExportToIsoWkt()
POINT M (1 2 3)
>>> print ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)').ExportToIsoWkt()
POINT ZM (1 2 3 4)


The OGRGeometry::DumpReadable() method used by ogrinfo uses this traditional 
form. There are other places where traditional WKT is used: CSV WKT export, 
...

I'm somewhat ambivalent about switching those places to the ISO compliant way. 
It would require adjustments in the autotest suite, and it's hard to evaluate 
the compatibility impact on third-party software. But on the other hand, it 
would probably a good time to do so.

Even


> 
> -Jukka Rahkonen-
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list