0

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

Farenhyte
  • 19
  • 4
  • 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 01 '23 at 10:04
  • 2
    Get the boundary of the polygon, create points along this line in regular intervals (see https://gis.stackexchange.com/questions/458751/generating-points-along-line-with-specifying-the-origin-of-point-generation-in-q) and get the raster value for each point (see e.g. https://gis.stackexchange.com/a/454447/88814) – Babel May 01 '23 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)? – Leigh Bettenay May 01 '23 at 10:32

1 Answers1

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.

Tom Brennan
  • 4,787
  • 6
  • 26