Created
March 5, 2012 10:58
-
-
Save saleiva/1977875 to your computer and use it in GitHub Desktop.
11870.com hotels density map in Madrid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT count(cartodb_id) as ct, ST_Transform(ST_Buffer(ST_SnapToGrid(the_geom,0.002),0.001, ‘quad_segs=2 endcap=square’),3857) as the_geom_webmercator FROM hoteles_playground GROUP BY ST_SnapToGrid(the_geom,0.002) | |
#hoteles_playground{ | |
polygon-fill:#FF6600; | |
polygon-opacity:.7; | |
} | |
#hoteles_playground[ct<=40]{ | |
polygon-fill:#BD0026} | |
#hoteles_playground[ct<=20]{ | |
polygon-fill:#F03B20} | |
#hoteles_playground[ct<=13]{ | |
polygon-fill:#FD8D3C} | |
#hoteles_playground[ct<=7]{ | |
polygon-fill:#FEB24C} | |
#hoteles_playground[ct<=3]{ | |
polygon-fill:#FED976} | |
#hoteles_playground[ct<=2]{ | |
polygon-fill:#FFFFB2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a fun bit of SQL, thanks! One does have to replace the smart quotes around
quad_segs=2 endcap=square
before the query will run, however.Plus, this snippet works somewhat on (multi)linestrings, depending on your data's density and the styling you apply. It does run a bit slowly the first time through, depending on your radii/etc, but I suppose that could also just be a limitation of the free hosted CartoDB (which is awesome, by the way). Here's what I ended up with after some fiddling:
... which can be seen in action here: http://bit.ly/GAVaB4