Last active
June 11, 2018 11:52
-
-
Save bubbobne/9a8d493ae9de4465987945825dd0f650 to your computer and use it in GitHub Desktop.
Create geoJSON from postGIS table, and other queries.
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
/** | |
*Create geojson | |
**/ | |
SELECT row_to_json(fc) FROM ( | |
SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM | |
(SELECT 'Feature' As type,ST_AsGeoJSON(lg.the_geom, 4)::json As geometry , | |
row_to_json((SELECT l FROM (SELECT value_1,value_2,value_3) As l | |
)) As properties | |
FROM my_table As lg ) As f ) As fc; | |
/** | |
* Check if there is duplicated points | |
**/ | |
SELECT a.gid as gid_1, b.gid as gid_2 FROM my_table AS a, my_table AS b WHERE ST_Intersects(a.geom, b.geom) AND a.gid <> b.gid; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment