QGIS Measure Distance Using Field Calculator

by bdwyer   Last Updated September 11, 2019 13:22 PM - source

I have a point shapefile with 80K+ records. Shapefile is projected in wgs84. The shapefile contains fields with the latitude and longitude of the point. I need a new field that contains a distance from a known point (Point B) in each record. Point B is the same for every record in the shapefile. There is a distance function in the field calculator (field calculator -> geometry -> distance). But I can't make sense of the syntax.

Example:

distance( geom_from_wkt( 'POINT(4 4)' ), geom_from_wkt( 'POINT(4 8)' ) ) → 4

What I want to do is measure the distance from the geometry of the current point to the geometry of a point I supply (for example point at "25.906543, -80.546800"). How do I refer to the current record using that tool and how to a create the new geometry? Is is something like:

distance( geom_from_wkt( 'POINT(25.906543, -80.546800)' ), 
($geometry ) )


Related Questions





calculate mean slope of lines

Updated February 06, 2018 12:22 PM

Select latest date with field calculator

Updated March 23, 2019 13:22 PM