Header

Sample raster values at point location in QGIS

Author: Paulo van Breugel
Updated on: 16-06-17

Introduction

If you need the values of a raster layer at specific point locations, there are various ways to do this in QGIS. You have for example the point sampling tool. There are furthermore the SAGA GIS function ‘Add grid values to point’ the GRASS GIS v.what.rast.points function. The latter two are available in the processing toolbox. Of course you can also use these tools in respectively SAGA GIS and GRASS GIS directly, but here I will show how to access and use these tools in QGIS.

Point sampling tool

In QGIS there are various methods / tools to sample raster values at point location. One of these is the point sampling tool, which provides an easy interface to collects polygon attributes from multiple layers (vector polygon and raster layers). You can install the plugin from the plugin manager. After installation, you can use open the tool in the menu (Menu: Plugins | Analyses | Point sampling tool). You will now be presented with a screen in which you need to select a vector point layer and the raster layer(s) from which to extract the values.

A disadvantage of this tool is that none of the fields in the original point layer is copied to the new one. So if the new point layer needs to include the attribute data from the original layer, you need to do an extra step, which is joining the two attribute tables using a spatial join. You can do this using the join attributes by location function (Menu: Vector | Data management tool | Join attributes by location).

SAGA function 'add grid values to points'

To use the Saga function ‘Add grid values to point’, you must have installed Saga GIS and than enable it in the processing options. To do this, go to: menu: processing – options and configuration – providers – SAGA and than select the Activate box. In Windows you will also have to define the path of the directory to which you installed SAGA.

After that, open the processing toolbox (go to menu: view – panels – toolbox) and look for the function ‘Add grid values to points’ in: SAGA – Shapes – Grid (easiest way to find that function is to start typing the name of the function in the search box). A new window will open:

Now select your point layer (1), one or more grid layers (2) and the interpolation method (3). If you simply want the grid values at point location, use the default ‘nearest neighbor’ method. Last, give the path and name of the output shapefile (alternatively, the function will create a temporary file, which you can than save using the save as option in the file menu.

v.what.rast.points function

The processing toolbox offers another tool to sample raster values at point location; the GRASS GIS v.what.rast.points function, which uses the v.what.rast function from GRASS. Suppose we have the raster layer ‘aspect’ and the point layers ‘SamplePoint’.

Now, need to add a column to the attribute table. In the example below I add the column ‘Aspect’.

Now, open the function v.what.rast.points in the processing toolbox. Easiest is to start typing the function name in the search field. Fill in the required fields (raster name, name of the column to which you want to upload the raster values, and optionally the file name of the new point layer.

After running the function, you’ll have a new vector layer, with an attribute table with the column ‘Aspect’.

The main difference with the SAGA ‘add raster values to point’ function is that first you will need to add the columns in which you want to store the raster values. So, a bit more work, but if you need to do this often, you can try to use the Processing modeler to create a new function / tool by chaining together the two different steps.