I know that QGIS can add values from a raster to a set of points on top of the raster through the SAGA "Add raster values to points" tool. However, I would like to generate the points themselves based on some threshold of difference in the raster values.

For example, over a body of water there would be few points generated because the change in elevation is small, but over a rugged mountainous terrain there would be more points to match the changes in elevation. Is there such a tool that QGIS has or can use through its Processing Toolbox?

2 Answers 2


SAGA TRI (Terrain Ruggedness Index) may help from the Processing toolbox to get a value which you can apply a threshold to. You can convert your TRI raster to ASCII XYZ GRID format with Raster/Conversion/Translate. Load the ASCII XYZ GRID as delimited text layer, remove points with TRI value below your threshold. Finally apply the Add raster values to points algorithm to get a point layer with X, Y, Z coordinates. The difficult points are to find the best parameters for TRI and the reasonable threshold value.

You can use the Graphical Modeller from the Processing menu to build a new algorithm with an input threshold value.


Another approach would be:

  • Turn the raster layer into polygon layer with categorical attributes, and then

  • Fill the polygon with points randomly, with its density reflecting the attribute value.

This will take these 4 steps, supported by 3 tools in Processing Toolbox:

  1. Processing | SAGA | Raster Tools | Reclassify values (simple) --- Convert continuous value of your raster cells into categorical/discrete data (such as 1, 2, 3, ...)
  2. Processing | SAGA | Vector to raster | Vectorising grid classes --- Create polygon layer in which an attribute "Gridout" holds the values from the above step 1.
  3. Layer Properties | Attribute Table | Field Calculator --- Create a new column to represent density of points, for each categorical value.
  4. Processing | QGIS geoalgorithms | Vector creation tools | Random points inside polygons (variable) --- To create random points. Number of points (density) is controlled by variables. Please choose "Points density" for Sampling strategy, and assign your density column to "Number field".

Please note it requires powerful CPU if you need to generate many points. But this Random points inside polygons tool is very unique.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.