Back to Code Snippets
DuckDB to geojsonSQL
Snippet helps put correctly formatted geojson file using spatial and json extensions from any table/query.
Execute this SQL
COPY ( SELECT *, -- all these field will become properties in resulting geojson (doesnt work well with map-like columns) ST_GeomFromText(wkt) as geometry -- this is the main geometry entry FROM temp_table ) TO 'test.geojson' WITH (FORMAT GDAL, DRIVER 'GeoJSON', LAYER_NAME 'test');
Copy code
Shabbir Marzban
Expand
Share link