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

Even Rouault even.rouault at spatialys.com
Thu Feb 11 02:25:14 PST 2016


Le jeudi 11 février 2016 11:15:33, Even Rouault a écrit :
> 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.

Hum reading what I've written above, we certainly want, at least, M and ZM 
geometries to be displayed as such by ogrinfo.
So yes I guess we have to switch to the ISO way (or implement a dual mode, 
where we use traditional way for XY and XYZ, and ISO way for XYM and XYZM ? 
Probably not a good idea)

Currently, if I have :

$ cat zm.csv
id,WKT
1,"POINT ZM (1 2 3 4)"

I get

$ ogrinfo zm.csv -al
INFO: Open of `zm.csv'
      using driver `CSV' successful.

Layer name: zm
Geometry: Unknown (any)
Feature Count: 1
Extent: (1.000000, 2.000000) - (1.000000, 2.000000)
Layer SRS WKT:
(unknown)
id: String (0.0)
WKT: String (0.0)
OGRFeature(zm):1
  id (String) = 1
  WKT (String) = POINT ZM (1 2 3 4) <-- this is just the string column, so 
ignore that
  POINT (1 2 3) <-- this is the geometry

Which is clearly not what we want


> 
> 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