-1

I have a raster file which contains polygons or lines I draw for mapping features. What I want to do now is extract along these polygons/lines the values from raster data and plot a graph of the elevations along the pixels. As in How to extract an arbitrary line of values from a numpy array?. Just that this time, its a polygon not a line

Community
  • 1
  • 1
Boikem
  • 39
  • 11
  • If I understand right, you have a raster and a polygons shapefile, and you want to extract the values near the polygons boundaries, is that right ? What do you mean by "near" ? Right under the boundaries ? – kaycee Jul 19 '16 at 16:20
  • Yh right under the boundaries – Boikem Jul 22 '16 at 13:55

1 Answers1

0

You will have to decide on a sampling interval. You can add points along the line/polygon edges at the desired interval, and then extract the raster value at those points (using gdal/numpy).

You need to be mindful of the relation between your raster resolution and sampling interval to avoid artifacts from "skipping" pixels or taking two samples in the same pixel, and you might want to apply some sort of filtering/interpolation on the resulting profile.

Benjamin
  • 11,560
  • 13
  • 70
  • 119