Skip to content

Instantly share code, notes, and snippets.

@cquest
Created July 16, 2014 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cquest/d1734a71c3a4a18587fe to your computer and use it in GitHub Desktop.
Save cquest/d1734a71c3a4a18587fe to your computer and use it in GitHub Desktop.
osm2pgsql point density mapnik query
(SELECT box, floor(10*log(count(*)+1)) AS nb
FROM planet_osm_point
JOIN
(SELECT ST_setSRID(ST_Makebox2D(ST_MakePoint(st_xmin(!bbox!)+x*!pixel_width!, st_ymin(!bbox!)+!pixel_height!*y),ST_MakePoint(st_xmin(!bbox!)+(x+1)*!pixel_width!,st_ymin(!bbox!)+!pixel_height!*(y+1))),900913) AS box
FROM
(SELECT generate_series(0,255) AS x) AS h,
(SELECT generate_series(0,255) AS y) AS v) AS b ON (way && b.box) group by b.box) AS density
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment