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 QGISOpen Quantum GIS and click the “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.
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”.
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 . 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”.
The GIS data for North America will appear in the data viewing area. Use the “Zoom In” tool to draw a box closely around the US, Canada, and Mexico.
To view the attribute table for this layer, right-click the layer and choose “Open Attribute Table” or click the icon when the layer is selected.
To edit your data, turn on the editor by clicking the “Toggle Editing” icon . Save your edits using the “Save Edits” button .
A simple way to identify features or query the attributes of a location is to use the “Identify Features” tool . 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”.
Now let’s add some labels. Select the n_america layer and click the “Labeling” button . Put a check next to “Label this layer”. Under “Field with labels”, choose “country” and click “OK”.
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.
|
liste
recherche
Friday, November 23, 2012
Working with your PostGIS Layers using Quantum GIS (QGIS)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment