Recently I received an excel file with the coordinates of 144 vegetation sample plots, with the request to get the altitude values for the plots. For those with little experience in GIS, this is easy enough in most GIS programs. Here is a simple tutorial/example how to extract raster values at point locations in QGIS.
Using plugins in QGIS
QGIS is a free and easy to use GIS program. Out-of-the-box it has limited tools for spatial analyses and data handling. But its capacities are expanding with each new version. Furthermore, there are a lot of plugins available that further extend its data handling and analyses options. Some come pre-installed, others can be easily downloaded and installed through the Plugin installer. Below I am using three plugins, the Add delimited text layer, the Point Sampling Tool and the Create zips from layers. You can find both under Plugins menu or in the Plugin toolbar (enable this toolbar under the View menu if needed).
If you can’t find the plugins, check under the Plugins menu | Manage plugins if these plugins are enabled. If they aren’t there either, you’ll have to download and install them. This is very easy; open the menu Plugins | Fetch Python Plugins. There is an official QGIS repository from where you can download plugins. Many more are available from third party repositories, which you can enable under the tab ‘Repositories’. Under the Plugins tab, you can select the plugins you want to install. Unfortunately the description is often very succinct, so it is not always clear what the plugins are for. But you can always install them to try them out or otherwise Google is your friend. After selecting the plugins you want, just click ‘install plugin‘.
I am assuming here that you are using the latest version of QGIS (as of this writing version 1.4.0). In older versions the vector tools (under Menu: Vector) are not included yet. If for whatever reason you don’t want or can’t install the latest version, you can get the vector tools as the separate plugin Ftools.
Creating a layer from a delimited text file
(1) You’ll need to export the spreadsheet to a text file (csv or tab delimited) first. You can then import the text file with coordinates as a point file in QGIS.
Menu: Plugins –> Delimited text –> Add delimited text layer
(2) Fill in the fields, e.g., see screenshot where I am importing a tab delimited text file.
(3) To spell out the obvious: check for errors. These are often easy to spot as outliers
(4) Save the file; right click with the mouse right on the just created layer in the Layers panel and select Save as shapefile...
(5) After filling in the Save as screen you will be asked to select the coordinate system. Make sure to fill in the same coordinate system as used on your GPS while recording the data. In this case the coordinate system was WGS 84 (EPSG 4326).
Sample one or more rasters at point locations
(7) Now open the newly created shapefile and the raster layer from which you want to extract the values at the location of the points. In this example we open the SRTM 90m Digital Elevation Model (DEM), which I downloaded from CSI-CGIAR. This data is available in 5 deg x 5 degrees tiles in the geographic coordinate system WGS84 datum.
(8) Now you can use the plugin ‘Point sampling tool’ to extract raster values at the location of the points in the point file.
Menu: Plugins | Analyses | Point sampling tool
after which you will see the following screen in which you need to select the raster layer(s) from which to extract the values and the point layer.
(9) Now, the new point file only contains the values extracted from the raster layer, none of the fields in the original point layer is copied to the new one. This is rather unfortunate, but luckily it is easy enough to join the values of the two vector layers using a spatial join:
Menu: Vector | Data management tool | Join attributes by location
(10) Now, you’ll have your shapefile with the original columns as well as a column with the altitude for each point. Because I have to send the resulting shapefile by email, I am using the Create zips from layers plugin to zip the shapefile. Look under the Plugin menu for this plugin.
Note that in QGIS you can also extract raster values at point locations using the GRASS GIS plugin. Alternatively, do this in GRASS GIS directly. This probably works better with very large data sets and of course if you want to store the vector map in a GRASS GIS database for later analyses. See here how.






Very usefull tool!
I was searching how to do the same thing simply with Grass and I didn’t find yet!!
If you know how to (with GRASS) do the same, I am interested in…
Thankyou!
Hi, see http://pvanb.wordpress.com/2010/05/05/upload-raster-values-to-vector-points-using-grass-gis/ for a short explanation how to do this in GRASS GIS.
Pingback: Upload raster values to vector points using GRASS GIS « Ecostudies
Great, exactly what I wanted ! Now I can do what I wanted to: compute the depth of points in a cave compared to the surface.
Just a remark: the plugin “Point Sampling Tool” (and “Create zips from layers”) doesn’t come automatically with QGIS, one has to go to menu Plugins > Fetch Python Plugins > tab Repositories > button “Add 3rd party repositories”, and then one can find them in the tab “Plugins” (that was not so obvious when reading your post).
Hi Florian, you are right, they need to be downloaded from the 3rd party repositories. Thanks for pointing this out. I am curious though how you would use QGIS to compute depth of points in a cave, sounds interesting in any case.
Thank you very much! Exactly what I was looking for.
Great, thanks. That point sampling tool is going to be very handy.
Hi, I’m new to QGIS and I am trying to make a visualization of a water body with 9 meters deep. I have data of 3 different depths (surface, middle and bottom) in 4 different points. I can make interpolation of individual depths, but I can’t give the depth to the layer. The different layers appear at the same level. I would like to know how can I insert the data so I can see the three layers and different levels?
Second is if I manage to make QGIS to read the data of depths, can I interpolated the interpolated raster with each others using the “Grid – interpolation” Tool?
Hope you can help me or send me to a tutorial..
Regards
Gonçalo
The point sampling tool and the Analyses plugin seem to have disappeared front he QGIS menu. Is there an alternative?
I am travelling at the moment, without access to the latest version of QGIS. However, I would be surprised those two plugins have disappeared. What version are you running?
If this happened after a QGIS update, make sure all plugins are installed and enabled. If they are not installed, and you can’t find them in the plugin installer, check if all repositories are enabled.
I only can check this further when back (next week), so I would recommend to post this question on the QGIS email list (but make sure to mention the version and when this happened).
I just checked and both plugins are available, so something else must have gone wrong.
Dear Pvnab, http://gis-techniques.blogspot.com/2012/10/extract-raster-values-from-points.html has some good tutorial on getting raster values based on points using Raster package in R, which may be useful for Statistics savvy GIS guys.
Thanks! Your quick introduction helped me a lot.
Thank you for this. I’m able to get far enough to check the attributes of the points I’ve extracted, but they all have the same value. Just looking at the raster, this isn’t the case. Is this a commonly known difficulty? Thanks in advance.
I apologize – through some experimentation, I found that the points, while displayed where expected, were actually pulling raster values from somewhere else and the raster was constant there. My misunderstanding is more basic.
Glad you found out the problem
Are you saying your points display at given locations, but get raster values from other locations? That sounds strange. Anything to do with the point layer and raster layer being in different projections? QGIS can handle that through on the fly projection, but I don’t know how/if the plugin can handle that (never tried).
Precisely that! I ended up using Raster -> Projections -> Warp to put them both in the same projection and, while the image didn’t change, the values from the Point Sampling Tool were correct.
Makes sense
. On the fly projection is just a aid to quickly combine data layers, even if they are in different projections, in one map. ArcGIS does also on-the-fly projection, which is used for display and query purposes. But I have seen people running into similar problems you had because they simply didn’t know ArcGIS was doing this (in QGIS you have to actually enable it I think, so you should be aware it is happening). In any case, for any analytical work the first step should always be to make sure all maps are using the same projections, extent and (if you are combining different raster layers) the same resolution.