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

Mateusz Loskot mateusz at loskot.net
Thu Nov 8 11:43:37 EST 2007


Gustavo Ces wrote:
> 
> 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? Thanks in advance,

Gustavo,

You can use linestring to one of rectangular system, projecting your
data to ie. UTM. Then you can use provided Distance function
based on the Pythagorean Th.

Another option is to use laws of spherical geometry and simple
approximations of distance. Here you can find it well explained with
implementation provided:

http://www.codeguru.com/Cpp/Cpp/algorithms/article.php/c5115/

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the gdal-dev mailing list