8

I have a table with geospatial objects, in particular, polygons. I know that I can generate from one row a geoJSON string using ST_AsGeoJSON(http://www.postgis.org/docs/ST_AsGeoJSON.html). But I would like to generate one geoJSON from all the table. Is this possible? How can I do it?

Thanks in advance

8

Already make a comment but in addition if you choose OGR2OGR, the way to export to GeoJSON is the following:

If you want to keep original SRS

ogr2ogr -f "GeoJSON" yourdataoutputname.geojson PG:"host=localhost user=username dbname=yourdatabasename password=yourpassword" "yourpostgistable"

If you want to convert to default SRS for GeoJSON (EPSG 4326)

ogr2ogr -f "GeoJSON" yourdataoutputname.geojson -t_srs EPSG:4326 PG:"host=localhost user=username dbname=yourdatabasename password=yourpassword" "yourpostgistable"
1

i think, you need generate row by row with this function ST_AsGeoJSON or export database/table with org2ogr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.