I'm trying to extract raster values along multiple shapefiles in QGIS for further analysis. I've successfully extracted values for points, so I either need to convert my vector shapefile to points (with the same spacing as my raster pixel resolution), or I need a tool to extract values along the vector line. I've tried Zonal Statistics, but I need to extract each pixel value, not the sum/count/mean etc.
-
Could you clarify how you want the pixel values to be attached to the line? It's not clear what kind of output you want. Are pixel values going to become multiple attributes of the polyline shapefile? Are you trying to trying to make some kind of plot like the change in elevation over a DEM transect?– ycartwhelenJun 14, 2018 at 19:47
-
I am hoping to make a histogram of pixel values. It'd be ideal if I could extract them in csv format with X and Y locations, but that's not necessary.– glacierguruJun 14, 2018 at 19:55
1 Answer
Try SAGA
Tool Profiles from lines (in QGIS Processng Toolbox | SAGA | Terrain Analysis - Profiles
), which extracts all cell values underlie the line you have given.
Activate the tool, then:
DEM
: Select your raster as input.Line
: Select your line layer.Name
: If you have multiple lines, then specify an (unique) ID field. It will help you to identify which line (aka "profile") the data belongs to.[x]
Each line as new profile
: You can leave it on.I think you would need
Nearest neighbour
as resampling method, to extract the cell values without any modification.
-
Does this still work now? I do not have the option
Each line as a new profil
. I am using qgis 3.24 and saga 7.3– LennApr 8, 2022 at 16:35 -
@Lenn I have just newly installed QGIS 3.24.1 and I do see that option.– KazuhitoApr 8, 2022 at 17:45
-
oh cool! That is kind of strange though:/ Is it named the "Profiles from Lines" algorithm?– LennApr 8, 2022 at 17:54
-
-