Last active
August 15, 2024 09:45
-
-
Save matt-baker/5461349 to your computer and use it in GitHub Desktop.
Select lat/long centroid from a polygon in PostGIS.
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 polygon centroid as latitude/longitude in PostGIS | |
SELECT | |
st_x(st_transform(ST_Centroid(the_geom),4326)) as lat, | |
st_y(st_transform(ST_Centroid(the_geom),4326)) as long | |
FROM table; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
x and y are swapped!