I have built up a somewhat large PostgreSQL database that contains primarily geospatial data. I am currently trying to export some of the data into a GeoJSON format so that I can tile it and use it with some maps (Mapbox).
For the first data set that I am working with, I wrote up a quick script that uses the following ogr2ogr command to export the data into the GeoJSON format.
ogr2ogr -f GeoJSON \
-progress \
nhd_$2.json \
"PG:dbname=$PG_DB host=$PG_HOST port=$PG_PORT user=$PG_USERNAME password=$PG_PASSWORD" \
-sql "select resolution, geom from nhd_hr_$2"
Due to the large size of the GeoJSON file that was exported, I then used geojsplit to break up the large GeoJSON file into smaller subfiles and I was then able to use the Mapbox tiling tool to create my tiles and then create a layer for my map.
However, now that I've moved on to the larger databases I keep running into issues where my connection to the database will timeout after only downloading 12-15GB of the data.
My initial thought was to split up my query into sub-queries, but I'm not entirely sure how I could do that. Are there any ways that I could change my approach to exporting the data? Or is there a way for me to break up this query into more manageable chunks?