I'm working on population data (point features), and I'd like to know their distance from the coast as shown in the image below. Would there be a way to create a field in the attribute table which would give for each point it's distance from the shore?

enter image description here


the idea is to get the distance to the boundary of your polygon.

You can convert it to a linestring first and it could be easier to handle :

Geometry tool > convert polygon to line.

then you have multiple choices

i saw a good use of Qgis tools here for a graphic solution and well explained : Nearest distance between point layer and line layer, QGIS

Or you could try to use Grass library and v.distance wich can fill your need i think.


Or Either try to go with Postgis and St_Distance if you know how to use Postgis.

I hope you will find your solution

  • cheers mate seems to be working alright
    – Tim56
    Dec 11 '18 at 17:23

Assuming that the coast is defined as a multiline in the 'Rivers' layer, with an attribute 'name', and one of those lines has the name 'Amazon':

Then, the expression in the Field Calulator to fill the field 'd_Amazon' in the layer containing the points should be:


Note that the distance will be calculated based on the coordinates of the entities in their own reference systems, so it is advisable that both layers have the same system assigned to them.

If the coast is defined in a layer of polygons, the expression works in the same way for the points that are outside the polygon, but returns 0 if the point is inside the polygon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.