How to import shapefiles from Python to PostGIS?

How to import shapefiles from Python to PostGIS?

I want to import shapefiles to PostGIS using Python with arcpy & psycopg2 to connect to PostGIS. I don’t want to use the existing shapefile loader nor ogr, just write my own import tool.

How to import spatial data into PostGIS database?

The most common data format for spatial data has traditionally been the ESRI shapefile. shp2pgsql is a command line tool to import ESRI shapefiles to the database. Under Unix, you can use the following command for importing a new PostGIS table:

How can I import data from OpenStreetMap to PostGIS?

OpenStreetMap: OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world. Many people refer to OSM as the Wikipedia of maps. If you seek easy ways to get an extract of the data, you can check for GeoFabrik for Shapefiles or osmdata.xyz for GeoPackages. OpenStreetMap data from Africa.

How to ingest shapefiles into a PostgreSQL repository?

Our GIS guys dump a lot of shapefiles into a repository. We would like to have an autoprocess that walks through folder as a scheduled task. We would like to add these into our Postgres geodatabase for some other processes we are currently developing

How to ingest a shapefile into a PostgreSQL database?

I am looking to walk through large amounts of shapefiles and have their geometries and file names loaded into out database. Here’s the gist of the core portions of the ingest function I have working so far

Can you make a GeoTIFF in psycopg2?

The hard part is getting something GDAL compatible into PsycoPG2 (especially without GDAL). If you can make a GeoTIFF of the data you’re interested in (using OpenCV or something else) then you’ve got a decent amount of the puzzle solved.

Can You import GDAL compatible raster into PostGIS?

PostGIS has support for a few GDAL compatible raster types, and can translate between them freely (well at the expense of cheap CPU cycles, at least). The hard part is getting something GDAL compatible into PsycoPG2 (especially without GDAL).