Sampling raster values at point locations in QGIS – an update

In a by now fairly old post I described how to sample raster values at point location in QGIS. The method I described used the ‘Point Sampling Tool’ addon. However, the function creates a new point layer, which only contains the values extracted from the raster layer. None of the fields in the original point layer is copied to the new one. It is possible to join the attribute table of the new vector point layer with the original attribute table afterwards using a spatial join as explained in that post. However, this will not work if your point data includes points with exactly the same coordinates.

Since I wrote that post, QGIS has come a long way. It now for example includes by default a processing toolbox which provides an easy and convenient interface to hundreds of functions from e.g., GRASS GIS and SAGA GIS. One of them will let you sample raster values at point locations too. Like the point sampling tool described earlier, it will create a new point layer with a new column for each raster layer sampled. The difference is that it will also copy over the columns that were already present in the original point layer.

The function I am talking about is the Saga function ‘Add grid values to point’. For this function to be available, 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:

add grid values to point function in the processing toolbox (a SAGA GIS function)
Figure: Add grid values to point function in the processing toolbox (a SAGA GIS function)

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.

8 thoughts on “Sampling raster values at point locations in QGIS – an update

  1. Pingback: Sampling raster values at point locations in QGIS | Ecostudies

  2. Katya

    Thanks a lot for your quite clear instructions, as for previous method and for this one! Your blog is wonderful, and you are doing really necessary work!

  3. Helen

    I’ve had a problem with the Saga function Add grid values to point. It produces a value that rounds up to an integer (however it does still display the value with a decimal i.e. 4.000000). This reduces the accuracy of our data and means we can’t use the tool

    Any other ideas to ensure the process doesn’t change the number at all would be greatly appreciated.

    1. Saga isn’t currently working for me in QGIS, but I just tried with Saga directly, using a real number raster layer. The function uploads the real numbers to the attribute table, without rounding. I therefore suggest you report your problem with the QGIS mailing list, there you are more likely to find a solution for your problem.

      In the meantime / alternatively, you can also use the v.what.rast.point function (this is a GRASS function available in the processing toolbox). I wrote a small how-to here: https://pvanb.wordpress.com/2016/04/14/sample-raster-values-at-point-location-in-qgis-yet-another-way/

  4. Pingback: Sample raster values at point location in QGIS – yet another way – Ecostudies

  5. Rose

    Hello,
    Thank you for this very informative blog, it is very helpful as I’m still pretty new to this. I am struggling a bit though to obtain values from my raster file in combination with my coordinate file. I have tried now several methods, such as the Point Sampling Tool and the function from GRASS that you described. However, I obtain empty results all the time (an extra column that is empty). My coordinate file (from csv) has exactly the same CRS as my raster file (I am using data from http://data.isric.org/geoserver/sg250m/wcs). I would like to try this SAGA function, but cannot find it in my QGIS, is it available in the latest QGIS version?

    1. Rose

      Hello,
      I actually figured it out, point sampling tool worked when I downloaded the files directly instead of connecting through qgis to the websites server.

Leave a comment