liste

Bonjour et bienvenue dans mon site ! Willkommen auf meiner Seite! welcome in my homepage! http://assistance-en-sig.blogspot.com/ SIG ; Bases de données ; Géomatique; Python; ArcGIS; QGIS;

recherche

Friday, November 23, 2012

Working with your PostGIS Layers using Quantum GIS (QGIS)

This tutorial will explain to the user how to connect QGIS to your PostgreSQL/PostGIS database and spatially view any of your tables containing a geometry column. PostGIS is a powerful database for GIS functions and data storage so it is nice to have a program to visually see the GIS data stored within the database.  QGIS is an easy to use open source GIS application and is ideal for data viewing, editing, and making maps.

Si vous trouvez ce document utile et interessant merci de faire un don en cliquant sur un lien publicitaire dans le cadre 

You are required to have a PostgreSQL database with PostGIS installed.  
To install PostGIS you can visit the following website 
This database will need a GIS table (contains a geometry type column). Follow the next few steps to import the shapefile to PostgreSQL using QGIS.

Importing Shapefile Data to PostGIS using QGIS

Open Quantum GIS and click the “Import Shapefiles to PostgreSQL" QGIS Import Shapefiles to PostgreSQL button. This will open SPIT (Shapefile to PostGIS Import Tool).

Start by creating a connection to your PostgreSQL database.  Under “PostgreSQL Connections” click the “New” button.  Add a name for your connection, and then enter the parameters for your database connection (Host, Database, Port, Username, and Password).  Click the “Test Connection” button and you should see a message saying “Connection to databasename was successful”.  Once this is successful, click OK.

QGIS PostGIS Connection

Select your server from the dropdown list and click “Connect”, a list of your schemas will appear in the Global schema dropdown menu.  Choose the schema where you would like to import the data. Now click the “Add” button and add your shapefile. Ensure the information is correct concerning the shapefile and click “OK”.

QGIS SPIT (Shapefile to PostGIS Import Tool)

Your shapefile is now added to your database. Next, we will view the newly added PostGIS data.

Viewing PostGIS Layers using QGIS

Click the “Add PostGIS Layer” button QGIS Add PostGIS Layer. This will open up a window.

Under “PostgreSQL Connections” select your server name from the dropdown list and click “Connect”.  You will see a list of your PostgreSQL schemas. Open the schema containing your GIS data to see a list of all available layers.  Select the n_america layer click “Add”.

QGIS Add PostGIS Table

The GIS data for North America will appear in the data viewing area. Use the “Zoom In” tool QGIS Zoom In to draw a box closely around the US, Canada, and Mexico.

QGIS Layer View

To view the attribute table for this layer, right-click the layer and choose “Open Attribute Table” or click the icon QGIS Open Attribute Table when the layer is selected.

To edit your data, turn on the editor by clicking the “Toggle Editing” icon QGIS Toggle Editing.  Save your edits using the “Save Edits” button QGIS Save Edits.

A simple way to identify features or query the attributes of a location is to use the “Identify Features” tool QGIS Identify Features. Click a location on the map to view its attributes.

Classifying your Data


Right-click the n_america layer and choose “Properties”. Under Symbology -> Legend Type, choose “Unique Value”. Under “Classification field”, choose “country” and click Classify. Each unique value in the country column will be given a random color. Click “OK”.

QGIS Symbology

Now let’s add some labels.  Select the n_america layer and click the “Labeling” button QGIS Labeling. Put a check next to “Label this layer”. Under “Field with labels”, choose “country” and click “OK”.

QGIS Map

This concludes our tutorial on working with PostGIS data with QGIS. The user should now know how to import shapefile data into a PostGIS database, load that layer in QGIS, view/edit the attributes, and symbolize the map according to its values.

If you find this tutorial useful please make a donation by clicking one of the ads (Adsense) thanks 

No comments:

Post a Comment