Tag Info

Hot answers tagged

13

The geopy module provides the Vincenty formula, which provides accurate ellipsoid distances. Couple this with the wkt loading in Shapely, and you have reasonably simple code: from geopy import distance from shapely.wkt import loads line_wkt="LINESTRING(3.0 4.0, 3.1 4.1)" # a number of other elipsoids are supported distance.VincentyDistance.ELLIPSOID = ...


8

Apart from, as @underdark says ST_Length() returns a cartesian distance between the two points which in an unprojected CS is meaningless in this case, I would go with the answer you get from PostGIS. Google Earth uses a spherical globe, whereas the WGS84 globe is a spheroid - it is slightly squashed at the poles. Over short distances, there won't be much ...


8

The principal radius of the WGS84 spheroid is a = 6378137 meters and its inverse flattening is f = 298.257223563, whence the squared eccentricity is e2 = (2 - 1/f)/f = 0.0066943799901413165. The meridional radius of curvature at latitude phi is M = a(1 - e2) / (1 - e2 sin(phi)^2)^(3/2) and the radius of curvature along the parallel is N = a / (1 - e2 ...


5

Replacing st_length with st_transform(way,4326)::geography solves the geodetic distance problem - thanks unicoletti!. Old Beechy Rail Trail | 47.2km Great Southern Rail Trail | 53.5km Ballarat-Skipton Rail Trail | 57.2km High Country Rail Trail | 63.7km East Gippsland Rail Trail | 97.6km ...


5

You are not using geodesic functions to calculate the length, which means that for a point there is an error factor of: cos( LATITUDE * pi() / 180 ) If you then multiply the calculated lenght by the error factor you should obtain a value pretty close to the actual trail length. For instance the Old Beechy Rail Trail is close to Melbourne, which has a ...


5

One option is to create a fishnet grid specific to your area of interest. By specifying one row and X columns, you can very efficiently create a series of lines. I describe this method in greater detail here and here for two similar situations. For fine control of individual line placement, use the editor. From the image, you can see I created 16 lines ...


5

it is much easier now in 10. Right click on the length field and select calculate geometry. you can select the pcs of the data or the document, then select the units.


5

The CRS of your project is probably set on a geometric CRS like WGS. Try setting it to the same one you used for the shapefile.


4

Unioning the tables together is one way: WITH alltables AS ( SELECT the_geom FROM D1_r UNION ALL SELECT the_geom FROM D2_r UNION ALL SELECT the_geom FROM D3_r ) SELECT sum(ST_Length_Spheroid(the_geom,'SPHEROID["WGS 84",6378137,298.257223563]'))/1000 AS km_roads FROM alltables; Incidentally if you want PostGIS 1.5+ you can use the Geography ...


4

You could also use Shapely's length property, i.e.: from shapely.wkt import loads l=loads('LINESTRING(3.0 4.0, 3.1 4.1)') print l.length


4

try to use following sql. ALTER TABLE network ADD COLUMN shape_leng double precision; UPDATE network SET shape_leng = length(the_geom); i hope it helps you...


3

If you can make the start of the line as coordinate locations in a table, then Add Field and Calculate Field values for the end coordinate locations (if the 30 m change is in both the X and Y or by an angle this may need trigonometry), then Make XY Event Layer for each set of coordinate pairs, Merge into one point file, and then use Points To Line with the ...


3

Let's first address the side note. "3D length" means the actual length of the path on the earth's surface represented by the polyline, accounting for the additional length contributed by its motion up and down. "Geodesic length" usually refers to the length of a path within a Riemannian manifold. There are at least two useful and reasonable ways in which ...


3

Coordinate Systems [...] Shapely does not support coordinate system transformations. All operations on two or more features presume that the features exist in the same Cartesian plane. Source: http://toblerity.org/shapely/manual.html#coordinate-systems Being shapely completely agnostic in reference to SRS, it's quite obvious that the length ...


3

As alfaciano says in shapely, the distance is the Euclidean Distance or Linear distance between two points on a plane and not the Great-circle distance between two points on a sphere. from shapely.geometry import Point point1 = Point(50.67,4.62) point2 = Point(51.67, 4.64) import math # Euclidean Dustance def Euclidean_distance(point1,point2): return ...


2

I'd use ogr2ogr (http://www.gdal.org/ogr/index.html) to do it directly but if you really must use python then there are python bindings (http://pypi.python.org/pypi/GDAL/) to let you do it.


2

do you mean inside the field calculator? in this case I suggest you to use python because starting from 10.0 it's the "official" language supported in ArcGIS 10.0 is the last ArcGIS version that uses VBscript, staring from 10.1 it will be deprecated and unsupported with Python in field calculator you have to use !Shape.length! or !Shape.area! (Python "!" ...


2

Answer: SELECT (SELECT sum(ST_Length_Spheroid("D1_r".the_geom,'SPHEROID["WGS 84",6378137,298.257223563]'))/1000 FROM "D1_r") AS km_roads1, (SELECT sum(ST_Length_Spheroid("D2_r".the_geom,'SPHEROID["WGS 84",6378137,298.257223563]'))/1000 FROM "D2_r") AS km_roads2, (SELECT sum(ST_Length_Spheroid("D1_r".the_geom,'SPHEROID["WGS ...


2

The "Improved Polygon Capturing" plugin will let you specify line lengths as you draw. The CAD Tools ortho tool will let you draw 90 degree angles. However, unfortunately it doesn't seem like the two will work together!


2

A slight modification of the answer linked in the comments would be to do a Summary Statistics to get the SUM of the Shape.Length field of the intersect feature class, using the FID field of the polygons a case field, and then Join Field that back to the polygon feature class. In the ArcMap 10.1 Python window, these commands worked for me: intersection = ...


2

If the data in the network table is either being updated or added, it would be wise to make a trigger function to update the data, so the line lengths are always up-to-date. To do this, make a trigger procedure, written in PL/pgSQL: CREATE OR REPLACE FUNCTION shape_leng() RETURNS trigger AS $BODY$BEGIN NEW.shape_leng := ST_Length(NEW.the_geom); RETURN ...


2

You could turn your raster into a polygon then run an intersect with this polygon layer with your line layer.


2

In QGIS start an edit session for your line layer, then open the attribute table. Click the Field Calculator button, create a new field with a "Double" data type, set the width and precision, then enter $length in the Expression area. When you click OK the length for each feature will be calculated. The length will be expressed in units of the layer's ...


2

No, but use can use PostGIS function ST_Length for that. It returns length in meters if way field is of geography type. That is, to get length in meters, convert it: ST_Length(ST_Transform(way, 4326)::geography).


1

Whne you create the shapefile, choose a CRS that is UTM, not WGS84. QGIS will recognise that the kml is WGS84 and convert to your choice. In that new layer, your calculations should then be in metres. http://www.icsm.gov.au/mapping/map_projections.html#utm_zones For instance, I use EPSG:28355.


1

"Sum line lengths" calculates length in the units of the input layer's CRS. So if the input layer is in WGS84, the results will be in degrees. If the input layer is in some UTM projection, it will be meters or feet. NOTE: Reprojecting on-the file does NOT change the results of length calculations. You have to reproject the layers permanently using "Save as ...


1

If you use bing map, you may use Openlayers plugin. The units of that are not real metres. They fit only at the equator, and get distorted the more to the poles you come. Try the UTM projection designed for your part of the world to draw the building with cad tools. If you don't have a suitable map in UTM projection, make a screen copy of the bing map with ...


1

ST_Length, when called on a geometry, reports in units of the spatial reference system. For EPSG:900913/EPSG:3857, the units are in Mercator meters, not in meters. At all points on the globe, a Mercator meter is at most 1 real meter. To do this there are two possible fixes Transform to an appropriate projection for your area. UTM, state plane and albers ...


1

You should try Add Surface Information and/or Add Z Information which are in the 3D Analyst toolbox.


1

Most probably your project CRS is set to default WGS84, that is lat/lon degrees. You better set the project CRS to that of the Geotiff you created. Then the values for vector grid are in the units of the CRS. You can select min and max values to the ones you need, either by taking the values written on the map, or moving the mouse to the lines and noting ...



Only top voted, non community-wiki answers of a minimum length are eligible