[GIS] Assigning raster values to line and polygon by QGIS

attribute-joinsqgisrastervector

I have a raster data(.tif), and would like to assign its values to
line and polygon data by location.
Here, I'd like to take min, max, mean and median.

There is "Join attributes by location", but it only supports
joining between vector data and vector data.

Any tools or ideas ?enter image description here

Best Answer

For polygon feature, you can use Zonal statistics from raster -> Zonal statistics using QGIS 2.14.13 to get the min, max, mean and median of a raster:

enter image description here

enter image description here

enter image description here

But I am not aware of a tool that can get the same result using a line feature.

But as a workaround, you can create a small buffer polygon around the line and use Zonal statistics to get the min, max, mean and median, then intersect the original line with the buffered polygon to get a copy the attribute into the line feature.