How to read pixel values in RasterLayer that intersects line features of VectorLayer, applying Python in QGIS?

  • You have a tag for GDAL but make no mention of that software in your question body. Is that what you are using to try and do this?
    – PolyGeo
    Aug 28, 2018 at 6:01

1 Answer 1


in ArcMap application environment, there are multiple approaches to achieve desired objective, For example; you may extract underlying pixel values using 'Extract by Mask' tool available within ArcMap. The outcome of the tool will be another layer (raster) having pixels (with values) from intersection of input line feature. Results from Extract by Mask

Secondly, you may also convert your line feature into points (at specified interval) and then extract underlying raster values to these points. For the purpose, you have to create a point feature layer/Shapefile to carry extracted values in its table. Thereafter, start editing your line feature, select your line with select tool and then select 'Construct Points' available in Editor toolbar. You may change input parameters as per your requirement.

enter image description here

Hereafter, you can use 'Extract Values to Points' to get underlying raster pixel values in earlier created point feature class' table.

enter image description here

In case of DEM, an elegant way to extract raster values underlying line feature is to use 'Stack Profile' tool (3D Analyst)

enter image description here

I hope this works for you.

  • note that the question is for QGIS
    – radouxju
    Aug 28, 2018 at 8:18
  • yes, i try to develope in QGIS, i get a all bandvalue in raster but i need band value for intersects line features of VectorLayer Aug 28, 2018 at 8:27
  • You may replicate this approach in QGIS as well. There are almost same tools to facilitate you.
    – Rex
    Aug 28, 2018 at 10:06

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