[Gdal-dev] Calculating Polyline lengths in a file

matt.pettis at thomson.com matt.pettis at thomson.com
Wed Nov 8 11:14:02 EST 2006


I also received an email about determining units of the output by the SRS... as I am a newbie, can anyone point me to how I use the SRS (I assume it can be gleaned, or is the sum total of what is in the .prj file) to get my units?
 
tia,
matt

________________________________

From: gdal-dev-bounces at lists.maptools.org on behalf of Rob McCulley
Sent: Tue 11/7/2006 4:48 PM
To: gdal-dev at lists.maptools.org
Subject: RE: [Gdal-dev] Calculating Polyline lengths in a file



I needed to do this recently.  I wound up using python mapscript.  Here
is a snippet of the code that did it for me:

shpfile = mapscript.shapefileObj(gpsfilelocation)
totalLength = 0
for i in range(shpfile.numshapes):
    shp = shpfile.getShape(i)
    length = shp.getLength()
    totalLength = totalLength + length




-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of
matt.pettis at thomson.com
Sent: Tuesday, November 07, 2006 3:27 PM
To: gdal-dev at lists.maptools.org
Subject: [Gdal-dev] Calculating Polyline lengths in a file

Is there an easy way to calculate the lengths of polyline objects in a
shapefile (i have a shapefile of roads for a county, and want to find
the total length)?  Is there an OGR tool to do this, or does anybody
know of another tool?

I have done this halfway a hard way... I imported my file into
PostgreSQL/PostGIS, and applied length2d to it, and got a number.
However, I can't find documentation for what the units of the result are
in.  Does anybody know the answer to this question as well, as long as I
am here?

TIA,
Matt

_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.


_______________________________________________
Gdal-dev mailing list
Gdal-dev at lists.maptools.org
http://lists.maptools.org/mailman/listinfo/gdal-dev






More information about the Gdal-dev mailing list