[gdal-dev] exportToPrettyWkt and simplify

Even Rouault even.rouault at spatialys.com
Wed Apr 21 07:49:45 PDT 2021


Andrew,

Le 21/04/2021 à 16:31, Andrew Bell a écrit :
> exportToPrettyWkt() takes an argument called simplify. If it's set, 
> the FORMAT option is set to WKT1_SIMPLE before a call is made to 
> exportToWkt(). But it seems that WKT1_SIMPLE is also the default 
> format value for exportToWkt(). Perhaps I'm misreading, but it seems 
> like the simplify argument is potentially a no-op, depending on the SRS.

The default format value for exportToWkt() is "WKT1" (with axis and 
authority)

$ python -c "from osgeo import osr; srs = osr.SpatialReference(); 
srs.ImportFromEPSG(4326); print(srs.ExportToWkt(['FORMAT=WKT1_SIMPLE']))"
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 
84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]

$ python -c "from osgeo import osr; srs = osr.SpatialReference(); 
srs.ImportFromEPSG(4326); print(srs.ExportToWkt(['FORMAT=WKT1']))"
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 
84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]

$ python -c "from osgeo import osr; srs = osr.SpatialReference(); 
srs.ImportFromEPSG(4326); print(srs.ExportToWkt())"

GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 
84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]]

Depending on how the SRS has been built, you might get less differences 
between WKT1 and WKT1_SIMPLE, but the omission of AXIS should still be 
observed for the later

>
> Can someone explain what this argument is supposed to do and how I 
> might get WKT2 text out of this function?  I'm currently getting an error:
>
> PROJ: proj_as_wkt: DatumEnsemble can only be exported to WKT2:2019

Which GDAL and PROJ versions do you use ? and what is the reproducer for 
this issue ?

I suspect you might ingest a SRS from a WKT that contains a DATUM[] node 
and try to export that as WKT1something with PROJ < 7.2 (if I remember 
well). PROJ 7.2 got changes to automatically turn a DatumEnsemble as a 
Datum when exporting to WKT1.

Even

-- 
http://www.spatialys.com
My software is free, but my time generally not.



More information about the gdal-dev mailing list