Working with a PostGIS database in QGIS - axismaps/bcworkshop-collect GitHub Wiki

While it is possible to connect to PostGIS databases in ArcGIS, QGIS offers better native support. Once we configure the database connection, it is easy to quickly view data directly in the database. In this guide, we will:

  1. Configure and save the QGIS database connection
  2. Load the collected neighborhoods layer
  3. Export that layer to a shapefile

Configuring the QGIS database connection

Once QGIS is installed and running, open a new project and click the elephant icon to configure your database connection.

Then click new to setup a new database connection. (If your connection is already configured, select it from the dropdown and click connect).

Configure the connection parameters with the information provided and click OK.

The connection is now setup and saved with QGIS. You won't need to do this every time you open QGIS.

Loading neighborhoods data

Click Connect to connect to the database and load all the tables.

The neighborhoods will all be listed under the public schema. Click public to expand it then select neighborhoods_collection (the one with type of Polygon and the SRID of 4326). Then click Add to add it to the map.

You'll now see the collected neighborhoods in your QGIS window. You can use the information tool to get more information on each feature.

Exporting neighborhoods to a shapefile

To export the data from the database to a shapefile, right-click on the layer name in QGIS and go to Save As...

Ensure the format is set to ESRI Shapefile, give the file a name and choose the appropriate coordinate system (the default is probably best). Then click OK to save the data into a shapefile.