8

I have a point layer that shows the distribution of a species.

Is it possible in QGIS to convert this point layer to a raster grid in which the value of each cell corresponds with the amount of points within that cell?

Until now, I only managed to attach attribute values to the grid cells. I have already added a column in my attribute table that has the value '1' for each point, hoping that there is a way to use a sum of attributes for each grid cell.

  • 1
    Just a quick note about your logic: If you just sum the values of 1 for each grid cell then you are very likely overestimating richness (if this is what you want to calculate) as this calculation does not check if a species has already been added to a gridcell. – Curlew Apr 28 '14 at 16:19
  • I have a species distribution pattern, one point per observed individual. I want to check for aggregation and link the distribution of the species to underlying habitat in GIS. Now many points are lying above and very close to each other, so for visualisation I woud like to 'simplify' this pattern and use a grid that shows the number of individuals that have been observed per cell. I hope this explains it a bit better. – Murphy Apr 28 '14 at 16:37
8

This is a kludge but it does work - haven't found a way to go directly from points to raster yet (but am hoping someone gives a solution here!).

Starting with a point grid (random points in the Serengeti from the Vector|Research tools|Random points tool):

enter image description here

Create a polygonal grid of the same extent and cell size as the raster you'd like to have (this from Vector|Research tools|Vector grid):

enter image description here

Use Vector|Analysis tools|Points in polygon, using the polygon grid and the point layer:

enter image description here

This gives you a new grid (here colour coded by the number of points in each polygon cell):

enter image description here

Now use Raster|Conversion|Rasterize to convert this to a raster, using the PNTCNT attribute for the raster values and the same cell size as chosend for the grid:

enter image description here

... giving a raster with values as per the points in each cell:

enter image description here

2

Easiest and most straight-forward way:

  • Assume you have a column with a unique point identifier (the species name)
  • Split your Point layer by this Attribute (QGIS -> Data Management -> Split)
  • Rasterize each individual point layer for instance with the GDAL Rasterize Tool, or the SAGA or GRASS tools available in the Processing Toolbox. Make sure that you use the same cell-size and resulting extent.
  • Simply sum up all generated Rasterlayers. For instance with the SAGA function "Grids sum" or within GRASS "r.sum". Both functions are available in the Processing Toolbox as well.

In order to do this automatically I would suggest you ether write yourself a script, a processing-model or click x times on batch-processing in the QGIS Processing Toolbox. EDIT: If you are capable of using R then just start directly from here and adapt the code to your needs (looping through splitted points).
Or you wait for a little longer. In my freetime I am currently in the process of writing a new plugin for QGIS (dealing with macroecological calculations) and It might have a function similar to what you need.

  • I think the question relates to a single species layer - which can't (and shouldn't) be split for a solution. OP needs a 'sum of points in raster cell' solution. – Simbamangu Apr 28 '14 at 18:01
  • Well you can do it without splitting, but this requires almost certainly a loop, respectively a scripted solution. For a single species your solution is working of course as it simply shows aggregated occurrence density. – Curlew Apr 28 '14 at 18:32
-1

I found this lack of support in QGIS to be very annoying because it is one important geoprocessing step that I always need. Rasterizing via the fishnet, as suggested above, is very slow if you have a lot of data-points (say 100.000) because it performs a vector based operation that consumes your CPU. Furthermore, the fishnet is massive in size compared to a sleek raster layer.

GDAL has functionality to do this operation in a minimum amount of processing time but it is not implemented in QGIS (unfortunately). For the sake of the environment and your nerves, you can use the gdal function, however, on the command line or in other software environments. I prefer to use R that has serveral GDAL related packages. You can see how to do it in R at at Rasterizing polygons with the function "gdal_rasterize" in R.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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