[QGIS-Developer] WKT from QgsGeometry incompatible with OGR

Jorge Gustavo Rocha jgr at di.uminho.pt
Sat Jul 6 01:33:41 PDT 2024


Hi,

I second Even argument and I would prefer to change QGIS implementation. 
It does not make sense to have QGIS WKT strings not compatible with 
other Python tools (based on GEOS/JTS, like shapely, for example) and ogr.

 >>> import shapely
 >>> shapely.to_wkt(shapely.Point(0, 0, 0))
'POINT Z (0 0 0)'
 >>> shapely.from_wkt('POINT Z (0 0 0)')
<POINT Z (0 0 0)>

Regards,

Jorge  Gustavo

On 06/07/24 07:56, Even Rouault via QGIS-Developer wrote:
> Hi,
>>
>> Both formats are compliant with the WKT specifications.
>
> Are they? I may have missed something in the Simple Features spec, but 
> looking at https://portal.ogc.org/files/?artifact_id=25355 , I can't 
> see where it would allow the form {geometryTypeName}Z without a space 
> between {geometryTypeName} and Z.
>
> For example the BNF at page 56 shows:
>
> <point z tagged text> ::= point z <point z text>
>
> The examples at page 62 also show a space.
>
> Even
>
>>
>> Nyall
>>
>>
>>     A minimal example is below. Executing it will return an exception:
>>     "RuntimeError: OGR Error: Corrupt data"
>>
>>     from osgeo import ogr
>>
>>     qgis_geometyry = QgsGeometry().fromWkt("POINT Z (0 0 0)")
>>     wkt = qgis_geometyry.asWkt() # 'PointZ (0 0 0)'
>>     ogr.CreateGeometryFromWkt(wkt)
>>
>>     _______________________________________________
>>     QGIS-Developer mailing list
>>     QGIS-Developer at lists.osgeo.org
>>     List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>     Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>> _______________________________________________
>> QGIS-Developer mailing list
>> QGIS-Developer at lists.osgeo.org
>> List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer
> -- 
> http://www.spatialys.com
> My software is free, but my time generally not.
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info:https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20240706/c9940b07/attachment.htm>


More information about the QGIS-Developer mailing list