Created
October 3, 2017 14:13
-
-
Save Tab3r/dc15dbdc576e1a7ef0f8a2cf07958e6a to your computer and use it in GitHub Desktop.
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
SELECT jsonb_build_object( | |
'type', 'FeatureCollection', | |
'features', jsonb_agg(feature) | |
) | |
FROM ( | |
SELECT jsonb_build_object( | |
'type', 'Feature', | |
'id', gid, | |
'geometry', ST_AsGeoJSON(geom)::jsonb, | |
'properties', to_jsonb(row) - 'gid' - 'geom' | |
) AS feature | |
FROM (SELECT * FROM input_table) row) features; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment