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

Even Rouault even.rouault at spatialys.com
Fri May 7 02:21:19 PDT 2021


Le 07/05/2021 à 10:47, Daniel Evans a écrit :
>
> 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?
>
yes, you should use AddPoint_2D(), although it is admittedly a bit 
counter intuitive.
>
> *Dr Daniel Evans*
>
> *Software Developer*
>
> e: ​ 	*Daniel.Evans at jbarisk.com* <mailto:Daniel.Evans at jbarisk.com>
> t: 	*+44 (0)1756 799919* <tel:+44%20(0)1756%20799919>
>
> 	
>
> *www.jbarisk.com* <http://www.jbarisk.com/>
>
> Facebook <https://www.facebook.com/TheFloodPeople>
>
> 	
> LinkedIn <https://www.linkedin.com/company/jba-risk-management/>
>
> 	
> Twitter <https://twitter.com/JBARisk>
>
> 	
> YouTube <https://www.youtube.com/channel/UC0iatom2jYbW96voW0rlpCw>
>
> 	
>
> 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 at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3addc901/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image309140.png
Type: image/png
Size: 9886 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3addc901/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image784540.png
Type: image/png
Size: 651 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3addc901/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image864267.png
Type: image/png
Size: 715 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3addc901/attachment-0007.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image135223.png
Type: image/png
Size: 966 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3addc901/attachment-0008.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image644139.png
Type: image/png
Size: 784 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210507/3addc901/attachment-0009.png>


More information about the gdal-dev mailing list