Wednesday 12 July 2017

How to calculate distances in QGIS field calculator?


So I'm using qgis 2.6.0 and I have a csv (converted into a .shp) with two geometry columns, I want to create a new column with the distance between the two geometry:


shot.lat    shot.lon    haul.lat    haul.lon
57.563 -12.986 57.534 -12.985
57.7 -13.304 57.67 -13.299
57.611 -13.529 57.582 -13.538
57.594 -13.294 57.565 -13.315

57.432 -13.314 57.402 -13.304
57.339 -13.053 57.311 -13.072

I am trying to use the function geometry function "distance" with the following expression:


distance( geomFromWKT( 'POINT("shot.lon" "shot.lat")' ) , geomFromWKT('POINT( "haul.lon" "haul.lat")' ))

This should then create a new field with the distance between the points. When it runs though, it just returns Null. Am I missing something obvious?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...