Last active
August 29, 2015 14:07
-
-
Save peterdesmet/8537e58ab1609b3cadf1 to your computer and use it in GitHub Desktop.
Transform Belgian Lambert to WGS84 in PostgreSQL
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
-- SetSRID defines the datum. Use 31370, not 31300 for Belgian Lambert 72 | |
SELECT | |
*, | |
ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326) as geom_from_lambert, | |
ST_Y(ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326)) as latitude_from_lambert, | |
ST_X(ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326)) as longitude_from_lambert | |
FROM table_name | |
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
UPDATE table_name SET latitude_from_lambert = round(ST_Y(ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326))::numeric,7); | |
UPDATE table_name SET longitude_from_lambert = round(ST_X(ST_Transform(ST_SetSRID(ST_MakePoint(x,y),31370),4326))::numeric,7); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
geom_from_lambert
seems to be interpreted as a string, not sure what function is required to make this a geometry.