How to convert from PostgreSQL to GeoJSON format?
问题 I have a simple table called"imposm3_restaurant" with columns [ id, name, geometry] I want to convert these data into geoJSON, I am using this function CREATE VIEW imposm3_restaurants_geojson AS SELECT row_to_json(fc) AS geojson FROM (SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features FROM (SELECT 'Feature' As type, ST_AsGeoJSON((lg.geometry),15,0)::json As geometry, row_to_json((id, name)) As properties FROM imposm3_restaurants As lg) As f ) As fc; and the result is