I am attempting to calculate the distance from a point to the nearest polygon edge (county boundary). I have approximately 80 points and want to find the closest county edge for all of the points and calculate the distance in miles. I am using QGIS because I only have a basic license in ArcGIS Pro. I have tried all of the distance tools with no luck. I read about the NNJoin plug-in, but I can't seem to get that to work either.

Can you advise?


2 Answers 2


You can:

  1. Convert your polygons to lines with "Polygons to Lines"

  2. Calculate the distance to nearest line with Field Calculator. Change Lines to the name of your line layer:

distance($geometry, array_first(overlay_nearest(layer:='Lines', expression:=$geometry)))*0.000621371192

which measures the distance from each points geometry to the nearest lines geometry.

My coordinate system is in meters so I multiply the result with 0.0006... to get miles

enter image description here (Field type should be Decimal number (Real), not integer)

  • Is there a way to do this and tell it a specific points layer? I have multiple in my project. Jun 16, 2023 at 10:45
  • 1
    That's what I'm doing. I've opened the attribute table of the "Random points" layer and Field calculating it
    – BERA
    Jun 16, 2023 at 16:19

To create a line from the point to the closest point on the boundary of the nearest polygon and then measure the length of that line, use this expression:

    make_line (
        closest_point (
                overlay_nearest (
                    'polygon',  -- change to the name of your polygon layer

A modofied version of the expression (to convert m to km and round the result) labels to point layer with the distance to the nearest point on the polygon's boundary - thus the length of the black lines that are added for visualiziation purpose only:

enter image description here

  • Is there a way to specify the points layer? My project has multiple. Jun 16, 2023 at 10:48
  • 1
    You apply the expression on the point layer, so you choose which one it is.
    – Babel
    Jun 16, 2023 at 12:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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