<div dir="ltr">Hi Rich,<div><br></div><div>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:</div><div><br></div><div>>>> from osgeo import ogr<br>>>> g = ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)')<br>>>> g.CoordinateDimension()<br>4<br>>>> g.GetCoordinateDimension()<br>3<br></div><div><br></div><div>Dan</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Jun 29, 2026 at 2:45 PM Richard Greenwood via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>In Python, I want to find the coordinate dimension of my source. For example,<span style="background-color:transparent"> with a postgis table with geometry(MultiLineStringZM,4326). My Python:</span></div><blockquote style="margin:0px 0px 0px 40px;border:medium;padding:0px"><div>in_lyr = in_ds.ExecuteSQL(select)</div><div>feature0 = in_lyr.GetNextFeature()</div><div>feature0_geom = feature0.GetGeometryRef()</div>feature0_geom<span style="background-color:transparent">.GetGeometryType()        # 3005</span><div>ogr.GeometryTypeToName(3005)            #  '3D Measured Multi Line String'</div>feature0_geom.GetCoordinateDimension()<span style="background-color:transparent">  # 3</span></blockquote><div>Based on: <a href="https://gdal.org/en/stable/api/vector_c_api.html#_CPPv425OGR_G_CoordinateDimension12OGRGeometryH" target="_blank">https://gdal.org/en/stable/api/vector_c_api.html#_CPPv425OGR_G_CoordinateDimension12OGRGeometryH</a></div><div>I am expecting the coordinate dimension to be 4. Am I approaching this incorrectly?</div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Richard W. Greenwood<br></div></div></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>