[Gdal-dev] How to measure a distance betwen two points on a line

Gustavo Ces g.ces at pettra.es
Thu Nov 8 07:10:29 EST 2007


----- Original Message ----- 
From: "Gustavo Ces" <g.ces at pettra.es>
To: "Jose Luis Gomez Dans" <josegomez at gmx.net>
Sent: Thursday, November 08, 2007 12:20 PM
Subject: Re: [Gdal-dev] How to measure a distance betwen two points on a 
line


> Hi Jose
>
>    Thanks for answering. I´d love to getPoint() but i can´t because my 
> feat.GetGeometryRef() returned doesn´t have this method!
>    feat.GetGeometryName() returns ' Linestring" and in ogr page i can see 
> a getPoint() method  for that type of class. May i have to convert my 
> geometry to linestring ? How?
>    Now i can access to point coordinates ( with GetX and GetY) but that´s 
> all.
>    I see a get_length too, but only for linestring classes... Snif!
>
> Gus
>
> ----- Original Message ----- 
> From: "Jose Luis Gomez Dans" <josegomez at gmx.net>
> To: "Gustavo Ces" <g.ces at pettra.es>; <gdal-dev at lists.maptools.org>
> Sent: Thursday, November 08, 2007 11:58 AM
> Subject: Re: [Gdal-dev] How to measure a distance betwen two points on a 
> line
>
>
>> Hi Gus,
>> -------- Original-Nachricht --------
>>>     I´m making a python script and i need to measure the distance betwen
>>> two points on a line ( not the euclidean distance; sometimes there´s a 
>>> lot
>>> of points betwen them...). I see the Distance() method but it seems it
>>> compares the euclidean distance betwen two geometries. Is there any ogr 
>>> method
>>> to achieve my goal?
>>
>> Maybe someone can provide more insight, but my idea would go along the 
>> lines of using some sort of geoprocessing to split the bit of line 
>> between your two points (you can use getPoint(point_position) to get your 
>> point's geometry). In this resulting line, you can then measure its 
>> length.
>>
>> A similar way of doing this (skipping the geoprocessing bit, which might 
>> be non-trivial) is to search for your first point (->getPoint(), 
>> Equals()?), and copy that into a new line object, adding new points up to 
>> your last point of interest. You can then use the
>>
>> You don't want to use Distance, as that gives you the distance between 
>> the geometries, not length along line, which is what you're looking for.
>>
>> Hopefully, someone more knowledgeable than me will be able to help!
>>
>> Jose
>> -- 
>> GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
>> Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
> 




More information about the gdal-dev mailing list