In QGIS 3.28.2 Firenze I'm working on developing a QGIS plugin to get the elevation along the boundary of a polygon.

Given a shapefile polygon and a raster, I've been able to think of one solution:

  • Take the shapefile, shrink it by 0.95, get the difference (which is basically a thick boundary of the shapefile in polygon format, rather than line, and clip it to the raster to get a line of elevation.

What I'm looking for is a boundary of the shapefile, having the elevation data, as a raster. In other words, a raster in the form of a boundary line of the shapefile. The original problem statement is, "Find the elevation along the boundary of a polygon".

Shapefile after shrinking and using Difference tool with the original and the shrunk one

After clipping the difference shapefile with the raster

  • 3
    Have you looked at the profile tool plugin to see how they do it and if you can adapt that code to use a polygon's exterior ring as input?
    – Ian Turton
    May 1 at 10:04
  • 2
    Get the boundary of the polygon, create points along this line in regular intervals (see gis.stackexchange.com/questions/458751/…) and get the raster value for each point (see e.g. gis.stackexchange.com/a/454447/88814)
    – Babel
    May 1 at 10:16
  • 2
    You could improve the likely answers by asking yourself what exactly you want as an end-product. Do you want a line "profile" representing the perimeter with elevations at per-determined distances along the perimeter (irrespective of direction), or do you want a polygon with elevation values at each node (essentially a 3-d polygon)? May 1 at 10:32

1 Answer 1


If you are just looking to make improvements to the approach you suggest above, you could do the following:

  1. Convert the polygon to a line - use Polygons to Lines tool
  2. Buffer the line (Buffer tool)
  3. Clip the line using your original polygon (Clip tool)

enter image description here

You can then clip the elevation raster using this polygon, which should be a consistent width around the boundary.

  • Thank you, it worked as I wanted.
    – Farenhyte
    May 5 at 15:54

Your Answer

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

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