How to provide a geojson from postgrest? #1894
-
Environment
Description of issueI would like to get a geojson with featurecollection |
Beta Was this translation helpful? Give feedback.
Answered by
steve-chavez
Jul 8, 2021
Replies: 1 comment 3 replies
-
Hey @npltr62,
Yeah, this feature is not yet merged: #1564 For now you can create a view for getting geojson, like: create view shops_geojson as
select st_asgeojson(x) from shops x; Then call it through PostgREST: GET /shops_geojson
{"type": "Feature",
"geometry": {"type":"Point","coordinates":[-71.10044,42.373695]},
"properties": {"id": 1, "address": "1369 Cambridge St"}
} Edit: For a feature collection create view shops_geojson as
select json_build_object('type', 'FeatureCollection', 'features', json_agg(ST_AsGeoJSON(x))) from shops x; |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
wolfgangwalther
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @npltr62,
Yeah, this feature is not yet merged: #1564
For now you can create a view for getting geojson, like:
Then call it through PostgREST:
Edit: For a feature collection