Re: confused about coordinate dimension

Richard Greenwood via gdal-dev <[email protected]> Mon, 29 Jun 2026 13:00:33 -0600
Newsgroups gmane.comp.gis.gdal.devel
Message-ID <CAHBySPbp+J_6itT8ASgY=b2uxhfq7eTATB7qoU=aYWe7j8W+dA@mail.gmail.com>
--===============2579972322447444981==
Content-Type: multipart/alternative; boundary="00000000000062f1ed065569133a"

--00000000000062f1ed065569133a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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=E2=80=AFPM 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 =3D ogr.CreateGeometryFromWkt('POINT ZM (1 2 3 4)')
> >>> g.CoordinateDimension()
> 4
> >>> g.GetCoordinateDimension()
> 3
>
> Dan
>
> On Mon, Jun 29, 2026 at 2:45=E2=80=AFPM 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 =3D in_ds.ExecuteSQL(select)
>> feature0 =3D in_lyr.GetNextFeature()
>> feature0_geom =3D feature0.GetGeometryRef()
>> feature0_geom.GetGeometryType()        # 3005
>> ogr.GeometryTypeToName(3005)            #  '3D Measured Multi Line Strin=
g'
>> feature0_geom.GetCoordinateDimension()  # 3
>>
>> Based on:
>> https://gdal.org/en/stable/api/vector_c_api.html#_CPPv425OGR_G_Coordinat=
eDimension12OGRGeometryH
>> 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
>>
>

--=20
Richard W. Greenwood

--00000000000062f1ed065569133a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Dan - Thanks for the answer. If I had read the documentati=
on a little more closely I might have noticed &quot;Deprecated:<br>use OGR_=
G_CoordinateDimension()&quot;. Sorry for the noise.</div><br><div class=3D"=
gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On=
 Mon, Jun 29, 2026 at 12:58=E2=80=AFPM Daniel Baston &lt;<a href=3D"mailto:=
[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid=
 rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr">Hi Rich,<div><br></div=
><div>I&#39;m sure there&#39;s a historical reason for this, but it looks l=
ike GDAL has two very similar methods: GetCoordinateDimension() and Coordin=
ateDimension(). The former, rather surprisingly, returns only 2 or 3. The l=
atter one returns the value you&#39;re looking for:</div><div><br></div><di=
v>&gt;&gt;&gt; from osgeo import ogr<br>&gt;&gt;&gt; g =3D ogr.CreateGeomet=
ryFromWkt(&#39;POINT ZM (1 2 3 4)&#39;)<br>&gt;&gt;&gt; g.CoordinateDimensi=
on()<br>4<br>&gt;&gt;&gt; g.GetCoordinateDimension()<br>3<br></div><div><br=
></div><div>Dan</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" =
class=3D"gmail_attr">On Mon, Jun 29, 2026 at 2:45=E2=80=AFPM Richard Greenw=
ood via gdal-dev &lt;<a href=3D"mailto:[email protected]" target=3D"=
_blank">[email protected]</a>&gt; wrote:<br></div><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg=
b(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>In Python, I want to=
 find the coordinate dimension of my source. For example,<span style=3D"bac=
kground-color:transparent">=C2=A0with a postgis table with=C2=A0geometry(Mu=
ltiLineStringZM,4326). My Python:</span></div><blockquote style=3D"margin:0=
px 0px 0px 40px;border-width:medium;border-style:none;border-color:currentc=
olor;padding:0px"><div>in_lyr =3D in_ds.ExecuteSQL(select)</div><div>featur=
e0 =3D in_lyr.GetNextFeature()</div><div>feature0_geom =3D feature0.GetGeom=
etryRef()</div>feature0_geom<span style=3D"background-color:transparent">.G=
etGeometryType()=C2=A0 =C2=A0 =C2=A0 =C2=A0 # 3005</span><div>ogr.GeometryT=
ypeToName(3005)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #=C2=A0 &#39;3D Me=
asured Multi Line String&#39;</div>feature0_geom.GetCoordinateDimension()<s=
pan style=3D"background-color:transparent">=C2=A0 # 3</span></blockquote><d=
iv>Based on:=C2=A0<a href=3D"https://gdal.org/en/stable/api/vector_c_api.ht=
ml#_CPPv425OGR_G_CoordinateDimension12OGRGeometryH" target=3D"_blank">https=
://gdal.org/en/stable/api/vector_c_api.html#_CPPv425OGR_G_CoordinateDimensi=
on12OGRGeometryH</a></div><div>I am expecting the coordinate dimension to b=
e 4. Am I approaching this incorrectly?</div><div><br></div><span class=3D"=
gmail_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signa=
ture"><div dir=3D"ltr">Richard W. Greenwood<br></div></div></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">gdal-dev@list=
s.osgeo.org</a><br>
<a href=3D"https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel=3D"norefe=
rrer" target=3D"_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</=
a><br>
</blockquote></div>
</blockquote></div><div><br clear=3D"all"></div><div><br></div><span class=
=3D"gmail_signature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_s=
ignature"><div dir=3D"ltr">Richard W. Greenwood<br></div></div>

--00000000000062f1ed065569133a--

--===============2579972322447444981==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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

--===============2579972322447444981==--