[gdal-dev] Ellipsoidal length of a line

Nicolas Cadieux nicolas.cadieux at archeotec.ca
Sat Jun 15 12:38:06 PDT 2019


Thanks every one for your help,

I found good packages out there.  I will probably go with Proj. I’am just surprised it’s not part standard libraries like Shapely or OGR since both can calculate line length.  Most packages look like they are made to calculate only two point at a time and not, for example, a WKT string with multiple nodes.  I guess calculating distance between each vertex would be the way to go.

Cheer, 
Nicolas

> Le 15 juin 2019 à 07:02, Thomas Knudsen <knudsen.thomas at gmail.com> a écrit :
> 
> In the PROJ package, the geod utility is included - you could do
> 
> echo lat0 lon0  lat1 lon1 | geod -I +ellps=GRS80
> 
> Where the "-I" indicates that you want to calculate the "inverse geodetic problem", i.e. you know where you are, and where you want to go, but you need to know how far to go and in which direction.
> 
> e.g.
> 
> $ echo 55 12 56 12 |geod -I +ellps=GRS80
> > 0d	-180d	111332.699 
> 
> Where the distance (in m) you look for is the third number on the output line. The two first are the forward and return azimuths respectively. 
> Otherwise, you could use the "proj_lp_dist()" entry of the PROJ API - cf. https://proj.org/development/reference/functions.html
> 
> (and probably you should continue this thread on the PROJ mailing list if you need additional assistance)
> 
> /Thomas
> 
>> Den lør. 15. jun. 2019 kl. 06.43 skrev Nicolas Cadieux <nicolas.cadieux at archeotec.ca>:
>> Thanks,
>> Could work but I think this will be too slow. I wonder how QGIS does it? I guess they use code from Proj.4.  If anyone has an other idea, shoot!
>> Cheers 
>> Nicolas 
>> 
>>> Le 14 juin 2019 à 13:20, Patrick Young <patrick.mckendree.young at gmail.com> a écrit :
>>> 
>>> Not exactly what you want, but you can do this with PostGIS by casting your geometry to the geography type:
>>> 
>>> https://postgis.net/workshops/postgis-intro/geography.html
>>> 
>>>> On Fri, Jun 14, 2019 at 10:26 AM Atle Frenvik Sveen <atle at frenviksveen.net> wrote:
>>>> Hi! 
>>>> 
>>>> Not sure if would want to use gdal for this task*, but take a look at this blog post: 
>>>> 
>>>> https://janakiev.com/blog/gps-points-distance-python/
>>>> 
>>>> 
>>>> *or if it's doable, i guess not, since the scope of gdal is reading/writing geospatial formats
>>>> 
>>>> -a
>>>> 
>>>> - 
>>>>   Atle Frenvik Sveen
>>>>   atle at frenviksveen.net
>>>>   45278689
>>>>   atlefren.net
>>>> 
>>>> On Fri, Jun 14, 2019, at 17:32, Nicolas Cadieux wrote:
>>>> > Hi,
>>>> > 
>>>> > I am trying to get the length of a line in python. (Not just the 
>>>> > straight length between the first and last nodes).  Using geopandas, 
>>>> > (therefore the Shapely lib) I am getting the euclidien distance even 
>>>> > though the dataframe holdings the line geometries has a CRS (WGS84, 
>>>> > zone UTM 18 S).  Obviously, the WGS84 Ellipsoid is not taken into 
>>>> > account.  
>>>> > 
>>>> > Can I do this with gdal/ogr? 
>>>> > 
>>>> > Thanks for the help
>>>> > Nicolas
>>>> > _______________________________________________
>>>> > gdal-dev mailing list
>>>> > gdal-dev at lists.osgeo.org
>>>> > https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>>> _______________________________________________
>>>> gdal-dev mailing list
>>>> gdal-dev at lists.osgeo.org
>>>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190615/0f84d341/attachment.html>


More information about the gdal-dev mailing list