Adding Spatial data from PostGIS database to QGIS Desktop

This post will demonstrate how to add GIS data from a PostGIS database hosted online using QGIS.

This tutorial assumes the user already runs a PostGIS server.

  1. Click on the ‘Add PostGIS Layers’ icon button on the main menu bar. See where cursor pointer ison the screenshot below.

d1

 

2.First click ‘Connect to select a connection to a PostGIS (Postgres in our own case)

d2

 

3.A dialog box will pop up prompting you to fill in the sign in credentials for the PostGIS server

d3

 

4.The database tables will be automatically loaded into the window.

Click to highlight the data table you want to add to QGIS.

Click Add button.

d4

 

5.In the previous screenshot, note that the SRID column is empty for the data selected.

In this case, a dialog box will pop up and you can select an appropriate CRS for the data. For our demo, its WGS 84

d5

 

6.The data table is loaded into QGIS as a vector layer as seen on the screenshot below.

d6

 

Part Two

 

In this instance, we don’t need all the data on a Table but just a section. We can use the ‘Set filter’option and add only the selection of the data we require.

1.We connect the PostGIS again and select a data table. This table contains the administrativeboundaries of several districts in a State.

d12

 

2.Our intention is to filter the table and add only the boundary polygon of one of the districts. Click on ‘Set Filter’ button as shown in the screenshot below

d13

 

3.The Query Builder dialog box opens. Compute a query that will sselect from the table where the nameof the district is IbadanNorth. You can click ‘Test’ to authenticate that there are no errors in the query. Click OK

d14

 

4.Click ‘Add’ on this window to load the selection into the map canvas of QGIS Desktop

d15

 

5.The selected district administrative boundary is displayed on the QGIS Desktop map canvas.

d16

 

Thank you for following the blog.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s