Skip to content

Instantly share code, notes, and snippets.

@tetrashine
Created March 15, 2021 18:52
Show Gist options
  • Save tetrashine/171d167d1636875dbbd6a3cacf26b9b1 to your computer and use it in GitHub Desktop.
Save tetrashine/171d167d1636875dbbd6a3cacf26b9b1 to your computer and use it in GitHub Desktop.
Cluster.sql
SELECT B.geom, COUNT(A.id) as count FROM
(
SELECT (ST_SquareGrid(0.1,
ST_GeomFromText('POLYGON((103.605655941305 1.15876249278089,103.605655941305 1.47078321442792,104.088483621717 1.47078321442792,104.088483621717 1.15876249278089,103.605655941305 1.15876249278089))', 4326)
)).*) B
LEFT JOIN cluster_locations A ON ST_Intersects(A.geom, B.geom)
GROUP BY B.geom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment