Skip to content

Instantly share code, notes, and snippets.

@alexanno
Created November 3, 2015 19:43
Show Gist options
  • Save alexanno/52198608b78650e8d305 to your computer and use it in GitHub Desktop.
Save alexanno/52198608b78650e8d305 to your computer and use it in GitHub Desktop.
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.geom, 4)::json As geometry
, row_to_json((SELECT l FROM (SELECT fylkesnr, navn) As l
)) As properties
FROM sandbox.fylker As lg ) As f ) As fc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment