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.ev...@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.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to