[gdal-dev] Should AddPoint(x, y) promote geometries to 3D?

Daniel Evans Daniel.Evans at jbarisk.com
Fri May 7 01:47:58 PDT 2021


Using the Python bindings on GDAL 3.2.1 / GEOS 3.8.1, adding a point to a 2D LinearRing automatically promotes it to a 3D geometry:

from osgeo import ogr
ring = ogr.Geometry(ogr.wkbLinearRing)
ring.GetGeometryType()  # 2
ring.GetCoordinateDimension()  # 2

ring.AddPoint(0, 0)
ring.GetGeometryType()  # -2147483646
ring.GetCoordinateDimension()  # 3


Given that the `z` argument for AddPoint is optional, I'd assumed that the behaviour was to leave a 2D geometry as 2D if only x and y are specified; the Python documentation doesn't include any notes on the behaviour. Does one have to always use AddPoint_2D when dealing with 2D geometries?


Dr Daniel Evans
Software Developer


e: Daniel.Evans at jbarisk.com
t: +44 (0)1756 799919
www.jbarisk.com
All JBA Risk Management's email messages contain confidential information and are intended only for the individual(s) named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
Please notify the sender immediately by email if you have received this email by mistake and delete this email from your system. 
JBA Risk Management Limited is registered in England, company number 07732946, 1 Broughton Park, Old Lane North, Broughton, Skipton, North Yorkshire, BD23 3FD, England.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3c12d5bc/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image309140.png
Type: image/png
Size: 9886 bytes
Desc: image309140.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3c12d5bc/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image784540.png
Type: image/png
Size: 651 bytes
Desc: image784540.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3c12d5bc/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image864267.png
Type: image/png
Size: 715 bytes
Desc: image864267.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3c12d5bc/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image135223.png
Type: image/png
Size: 966 bytes
Desc: image135223.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3c12d5bc/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image644139.png
Type: image/png
Size: 784 bytes
Desc: image644139.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3c12d5bc/attachment-0009.png>


More information about the gdal-dev mailing list