9

I'm wondering if anyone can point me to resources for making a heatmap entirely within PostGIS. I'm able to create a new raster with an empty band, but it's not clear to me how I can assign values based on the density of nearby vector features.

1

1 Answer 1

8

The only way I've thought about truly doing a heatmap and/or density map in PostGIS is to break down what density is really doing:

  • Create a grid of X cell size - this could be a vector dataset, rather than raster, and there are methods of doing this elsewhere on this forum
  • Determine the radius you want to look for points around each cell
  • For each cell, get the count of points within the radius around the cell using ST_DWithin
  • Your output is then the number of points per unit of the area of the radius you are searching

That's essentially what density is doing - different methods such as Kernel density are a bit more in depth, but maybe someone else can lend a more refined explanation of density as it relates to breaking it down into a problem like this...

While I haven't done this YET - this is something I've been meaning to try for a while, but have so far been successful using the QGIS Heatmap plugin and/or the QGIS Heatmap layer style - SO - if you want to try this out, we can refine this answer together...

1
  • 1
    I had thought along those lines as well. From the documentation it looks like that's the workflow that PostGIS envisions--creating a vector representation of the cell and then doing whatever spatial operation needs to be done. Commented Oct 14, 2016 at 18:59

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.