Export GeoJSON from PostgreSQL using Beekeeper Studio
Query > Download > Copy > Paste!
Update 2024-01-05: Added steps for saving a geojson file from pgAdmin.
Beekeeper Studio is an open source SQL editor written in NodeJS and Vue JS. The UI is clean and simple, and it has just the right amount of tools to get the job done. The query interface even has a handy Download button to export the results of a query. Using the Copy to Clipboard Copy Cell option we can extract GeoJSON directly from a PostGIS enabled PostgreSQL database to a computer without having to open QGIS or another GIS desktop or command-line tool.
- Open Beekeeper Studio and copy the following query, replacing your_table with your table name, and changing the geom fields and id field if need be.
|
- After the script runs, use the
DownloadCopy Cell option by right-clicking on the returned data to copy the contents to the clipboard. - Open a text editor such as VS Code and paste the data.
Use the Home button to go to the beginning of the text and delete “jsonb_build_object”.- Save the result as a .geojson file.
Using pgAdmin
- Execute the script above.
- Double-click the results row - make sure the view is on
code
. - Copy and paste into a text editor and save as a .geojson file.