[gdal-dev] confused about coordinate dimension
Richard Greenwood
richard.greenwood at gmail.com
Mon Jun 29 12:00:33 PDT 2026
Dan - Thanks for the answer. If I had read the documentation a little more
closely I might have noticed "Deprecated:
use OGR_G_CoordinateDimension()". Sorry for the noise.
On Mon, Jun 29, 2026 at 12:58 PM Daniel Baston <dbaston at gmail.com> wrote:
> Hi Rich,
>
> I'm sure there's a historical reason for this, but it looks like GDAL has
> two very similar methods: GetCoordinateDimension() and
> CoordinateDimension(). The former, rather surprisingly, returns only 2 or
> 3. The latter one returns the value you're looking for:
>
> >>> from osgeo import ogr
> >>> g = ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)')
> >>> g.CoordinateDimension()
> 4
> >>> g.GetCoordinateDimension()
> 3
>
> Dan
>
> On Mon, Jun 29, 2026 at 2:45 PM Richard Greenwood via gdal-dev <
> gdal-dev at lists.osgeo.org> wrote:
>
>> In Python, I want to find the coordinate dimension of my source. For
>> example, with a postgis table with geometry(MultiLineStringZM,4326). My
>> Python:
>>
>> in_lyr = in_ds.ExecuteSQL(select)
>> feature0 = in_lyr.GetNextFeature()
>> feature0_geom = feature0.GetGeometryRef()
>> feature0_geom.GetGeometryType() # 3005
>> ogr.GeometryTypeToName(3005) # '3D Measured Multi Line String'
>> feature0_geom.GetCoordinateDimension() # 3
>>
>> Based on:
>> https://gdal.org/en/stable/api/vector_c_api.html#_CPPv425OGR_G_CoordinateDimension12OGRGeometryH
>> I am expecting the coordinate dimension to be 4. Am I approaching this
>> incorrectly?
>>
>> --
>> Richard W. Greenwood
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
--
Richard W. Greenwood
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20260629/1588f367/attachment.htm>
More information about the gdal-dev
mailing list