Last active
January 8, 2023 11:31
-
-
Save mbforr/0013a8b54caa356cd345dba24ca0b744 to your computer and use it in GitHub Desktop.
Example Spatial SQL Post
This file contains hidden or 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
-- written for PostGIS | |
-- table states is US State Polygons | |
-- table capitals are US State Capital points | |
select | |
a.name, | |
a.id, | |
-- create a centroid of the state polygon | |
st_centroid(a.geom) as centroid, | |
-- measure the distance from the state centroid to the capital | |
st_distance(st_centroid(a.geom), b.geom) | |
from states a | |
join capitals b using (abbreviation) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment