Last active
August 29, 2015 13:56
-
-
Save wboykinm/9234487 to your computer and use it in GitHub Desktop.
PostGIS Point in polygon
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
-- Aiming for count of point_table points in polygons of polygon_table | |
WITH polygon_table AS b | |
SELECT b.the_geom_webmercator AS the_geom_webmercator, | |
COUNT(i.cartodb_id) AS points_count, | |
COUNT(i.cartodb_id)/ST_Area(b.the_geom) AS points_density, | |
1 AS cartodb_id FROM b, | |
(SELECT * FROM point_table) i | |
WHERE ST_Intersects(i.the_geom_webmercator, b.the_geom_webmercator) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment