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

Showing posts with label layer. Show all posts
Showing posts with label layer. Show all posts

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 

Friday, October 26, 2012

GIS Training with QGIS - Exercise 1: Vector layers and Symbology



Exercise 1: Vector layers and Symbology
 1. Install QGIS
 a) Windows users should download the OSGeo online installer (requires an Internet connection for the
installation) from  http://download.osgeo.org/osgeo4w/osgeo4w-setup.exe. Run the installer, and
choose “Advanced” setup. From the software list select to install  qgis-unstable. Verify that GRASS
is selected for installation, and choose all the gdal16 software libraries.
 b) Ubuntu Linux users can find ready-made packages from the UbuntuGIS software repository:
Details for adding this repo here: http://trac.osgeo.org/ubuntugis/wiki/UbuntuGISRepository
 c) MacOS users should install packages and required frameworks from:
http://www.kyngchaos.com/software/qgis
 d) Open a new folder Geodata and copy all the practice data layers from the CD into this folder.
 e) Make a subfolder “Exercises” under Geodata and save all work there.
 2. Start QGIS
 a) Re-arrange toolbars to find all buttons easily
 b) Disable all plugins except GPS, Delimited Text, GRASS, Quick Print.
 c) Under Settings->Options be sure that the CRS is set to “Prompt for CRS”.
 3. Load data
 a) Load the background tiff file HYP_HR_SR_W.tif from  the naturalearthdata.com directory
under Geodata\raster.
 b) Load all shapefiles from the naturalearthdata.com directory under Geodata\vector.
 c) In the Project Properties, set the projection to WGS84 (EPSG:4326).
 d) Choose “Unique Value” for the classification of the layer “states_provinces”. Use the ISO
column to give each country  a different outline color for its provinces. Set all the fill colors to
“None”.
 e) Color the rivers and lakes layers blue.
 f) Add labels to the populated_places layer. Use the Name_Town column as labels, and place the
labels below the points.  Use scale dependent rendering to label the layers only when zoomed in to a
scale of 1:3,000,000 or closer.
 g) Choose Graduated Symbol for the populated_places layer to display the towns with different
size symbols based on the POP_MAXI column. Enter a value of 4 in Number of classifications and
click Classify. Then change the symbol sizes such that larger populations are displayed by bigger
symbols.
 h) Display the countries layer with 70% transparency, setting a separate color for each country, and
thick dark outline.
 i) Zoom to Bosnia-Herzegovina and save a bookmark. Zoom to Serbia and save another bookmark.
 j) Save the QGIS project as Geodata\Exercises\Balkans.qgs
 4. Check the project
 a) Close QGIS and reopen the project (File->Open Recent Projects).
 b) Verify that all symbology has been saved and that the bookmarks work.