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 <[email protected]> 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 <
> [email protected]> 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
>> [email protected]
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>

-- 
Richard W. Greenwood
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to