Load Geodatabase (GDB) into PostGIS
Last updated on September 15, 2022.
Geodatabase files are typically created in ArcGIS and are typically the result of manual data editing. Geodatabases often contain multiple layers of both vector and raster data.
Normally, importing a geodatabase (.gdb) file into a spatial database like PostGIS requires the use of a command line tool like ogr2ogr
. However, installing GDAL and its dependencies can be difficult on some machines.
Here, you can upload your Geodatabase file and download it as a spatial .sql file. You can directly upload this .sql file to your PostGIS instance using the psql
command line tool. Or, you can choose to have us host it for you.
You must turn your geodatabase into a .zip
file before uploading. On Mac, right click and hit "Compress", or on Windows, right click and hit "Compressed file". Then upload the .zip
file.
Geodatabase Format Support:
- One layer imported
- Handles up to 256MB
- Detect encoding (UTF8, Latin1, etc)
Once the file is converted to PostGIS, you can either download the file as .sql
and upload to your database with psql
, or host the file with us for free. This file fits on our free plan, which is under 128MB of storage and shared compute time. Larger datasets can be stored for $2.50/GB/month.
Uploading to PostGIS (self-host)
To load your .psql file into your PostGIS instance (local, Amazon RDS, or other), you can use the psql
command line tool.
psql -U postgres -h localhost -d postgres -f downloaded_file.sql
Database Connection (managed)
If you choose Bunting as your host, connect to the PostGIS database with your username and password:
psql -W -U username --dbname data_gis \
-h pgexample.gis.buntinglabs.com
Password:
password
Done!
Connection can also be made through GeoDjango or GeoPandas, like so:
from sqlalchemy import create_engine
db_connection_url = "postgresql://username:[email protected]:5432/data_gis"
con = create_engine(db_connection_url)
sql = "SELECT geom, highway FROM target_table"
gdf = geopandas.GeoDataFrame.from_postgis(sql, con)