Getting Started with PostGIS – Import Shapefiles (SHP Files)

You will need a PostgreSQL server with PostGIS extensions enabled on a database.

Find some data you want to plot. A good free resource is https://hub.arcgis.com/

In this tutorial, we will use Internet Towers in Parkland County, Alberta, Canada. https://hub.arcgis.com/datasets/tempegov::accessible-service-providers

Install the PostgreSQL Client software if it is not installed to provide shp2pgsql

# dnf install -y postgis30_12-client

Download and convert the SHP file to Postgres and insert into the table

# su - postgres
$ cd /tmp
$ wget https://opendata.arcgis.com/datasets/26d6f206fa63417097712f14f85b2a69_0.zip
$ unzip 26d6f206fa63417097712f14f85b2a69_0.zip
$ shp2pgsql 0260890c-15bb-4802-ae91-d48265593dfa202047-1-16linhf.im31.shp | psql -d gisdb

You should see the data in pgAdmin 4. Click the eye icon to view on a map.

The data may also be viewed in QGIS.

Leave a Reply

Your email address will not be published. Required fields are marked *