Introduction This manual is aimed at users of the Rainforest Foundation UK's PostGIS database. It should be read by people wishing to upload and edit GPS survey data as well as by those who will administer the PostGIS database. The manual can be used as a practical tutorial and aims to teach users how to: Install the plugin Connect to the PostGIS database View data from the database Upload features to the database Populate and edit feature attributes in the database This guide assumes that the audience is already familiar with basic Quantum GIS tasks such as creating shapefiles, editing table attributes etc.
In the following chapters, we'll be creating tables in the PostGIS database based on GPS point and track data surveyed in the field. Each of the examples assumes that the user has already loaded their GPS data into QGIS, either directly using the Gps Tools plugin, or through the Add Vector Layer dialog. In this case, your screen should look something like this, with GPS data and background maps.
1. Installing the plugin IMPORTANT: If you already have a previous version of the plugin installed, uninstall it by removing the rfuk_postgis_upload folder from your ~/.qgis/python/plugins folder and restarting QGIS. The RFUK PostGIS Upload Plugin is located in a dedicated Quantum GIS python plugin repository. To install the plugin, we will first need to add the dedicated repository. 1. Open Quantum GIS 2. Select Fetch Python Plugins... from the Plugins menu 3. Click the Repositories tab 4. Click the Add button 5. Enter the details as shown in the image below and click OK Name: RFUK Repositry URL: http://postgis.mappingforrights.org/qgis-repo/plugins.xml
6. Click the Plugins tab 7. Type rfuk in the filter box and select the plugin in the list: 8. Click Install plugin A message should now be displayed to show that the plugin was successfully installed. The plugin can be accessed through its icon, By default, Quantum GIS will check for updates for plugins once a day. Quantum GIS will notify users when there is an update available for the plugin and prompt them to download and install it.
2. Setting up PostGIS connections In order the use RFUK's PostGIS database, you'll need to have been given a username and password. At present, a single login is used by each participating country. The username consists of the prefix remote_ followed by the name or abbreviation of the country. The following table shows a list of available usernames. Country Username Cameroon remote_cameroon Central African Republic remote_car Congo remote_congo Democratic Republic of Congo remote_drc Gabon remote_gabon Each username will have the following levels of access to different types of data within the database. The word country in the Dataset column should be replaced with the name of the country in which the surveyor is working. Dataset Dataset Description Access bg_country Background mapping specific to the country Read only bg_general Non country specific background mapping. These datasets Read only often cover multiple countries. country_draft Survey data that has been uploaded and is in the process of being edited or is awaiting approval Read / write country_approved Survey data that has been finalised and approved Read only It should be noted that surveyors have write access only to draft datasets. The following instructions will show how a PostGIS connection is created. 1. Open Quantum GIS and click the Add PostGIS Layer button, The Add PostGIS Table(s) dialog should now be shown.
2. Click the New button to configure a new connection. The Create a New PostGIS connection dialog should now be shown.
3. Enter your username in the Name and Username entries and fill out the other entries exactly as shown above. Your password should have been provided by Rainforest Foundation UK. 4. Click Test Connect Successful configuration should show the following:
3. Importing Data The RFUK PostGIS Upload Plugin can be used to upload the following geometry types to the database: Points Multilinestrings Multipolygons The plugin supports the upload of the following types of data: Villages (Point) External Actors (Point and Multipolygon) Livelihood and Cultural Activities (Point and Multipolygon) Natural Features (Point and Multipolygon) Routes and Local Rivers (Point and Multilinestring) For more information on the types of data that can be uploaded to the database and their supported attributes, refer to the RFUK PostGIS Table Attribute Standard (version 008). 3.1 Overview of the process When the RFUK PostGIS Upload Plugin's Upload button is clicked, the plugin does the following: Checks that the input layer is a vector layer Checks that the input layer is in WGS84 Lat/Lon projection Checks that some features are selected Checks that the table name matches the data type Connects to the PostGIS database and creates a new, empty PostGIS table with the correct attributes for the data type Copies each selected feature into the PostGIS database, re-projecting each feature to a sensible projection for the given country and copies any relevant data from the GPS survey into the correct columns of the database 3.2 Selecting features In order to upload to the database using the RFUK PostGIS Upload Plugin, features to be uploaded will first need to be selected. Selection can be performed by one of the following methods: 3.2.1 Manual selection (within Quantum GIS) Features can be manually selected using one of the selection methods of Quantum GIS.
3.2.2 Select by attributes (within Quantum GIS) Features can be selected based on their attributes using the search or advanced search options in a layer's Attribute Table dialog. 3.2.3 Select all (within the RFUK PostGIS Upload Plugin) The Select All button will select all features in the current layer. 3.2.4 Select based on dates (within the RFUK PostGIS Upload Plugin) The select based on dates feature allows the user to select features based on the GPS date stamp present in layers loaded directly from GPS devices or GPX files. This feature could be used, for example, to quickly select survey data from a particular day from a much larger collection of survey information. It is important to note that GPS time stamps will be in universal time (UTC) where the dates used for selection entered by the user are in local time. 3.3 3.4 Uploading data an example According to the RFUK PostGIS Table Attribute Standard (version 008), points can be used to represent villages, external actors, livelihood activities and cultural activities, natural features and routes. In this example, we'll add two surveyed villages, Carefour and Ngamakossou, from a GPS file containing multiple surveyed points. 1. Select the points to upload
Zoom in to ensure that the selection is correct 2. With the desired points now selected, open the RFUK PostGIS Upload Plugin using its button,
The plugin dialog should now be visible:
The dialog consists of controls associated with the upload of the data as well as controls associated with the selection of data to be uploaded. The selection tools allow the user to select features based on the date they were surveyed. This method of selection requires that the survey date is included in the comment attribute by the GPS device (it usually is). If the plugin cannot find the date in the comment attribute for some features, a warning will be issued to the user. The select all button selects all features in the GPX layer.
The upload controls allow the user to specify options relating to how the data should be inserted into the database. The first option is the PostGIS connection to use for the upload. It is important that the correct connection is used for a given country as the name of the schema that the data will be uploaded to is derived from the connection name. In this case we are uploading data located in Congo, so are using the remote_congo PostGIS connection. The next option describes the type of data we are uploading. In this case, the points being uploaded are villages, so we have chosen the Villages option. The data types correspond to the RFUK PostGIS Table Attribute Standard (version 008). The next option is the name to give the new PostGIS layer. Layer names can contain only lower case letters, numbers and underscores (the '_' character). The RFUK database specification specifies a naming convention for PostGIS layers enabling them to be easily identified. The name prefixes required for different data types are described below.
Data Type Table name prefix Villages v External Actors ea Livelihood Activities la Cultural Activities ca Natural Features nf Routes or Local Rivers rr 3. Ensure that the PostGIS Connection is set to remote_congo, the Type of Data is set to Villages and enter a name for the new layer, such as v test_layer_001 4. Click Upload If successful, the new PostGIS layer will be loaded into the table of contents on the left-hand side.
5. Next, open the attribute table of the PostGIS layer using the Open Attribute Table button, The table attributes for the two imported points should now be visible (your attributes may differ slightly from the image below). It can be seen that information from the GPS data has been copied to the database, such as the name of the waypoint and the date the waypoint was surveyed. Additional attributes such as the population of adult males and females has not been automatically populated. This data will need to be entered manually from within Quantum GIS.
4. Loading PostGIS survey layers In this chapter, the user will learn how to view survey data that already exists in the PostGIS database. PostGIS layers are loaded using the Add PostGIS Layer button, 1. Click the Add PostGIS Layer button to open the Add PostGIS Table(s) dialog 2. Ensure that the remote_congo connection is selected and click Connect A list of PostGIS layers should now be displayed. Layers are grouped into containers called schemas. Background data will be located in schemas starting with bg_ while survey data will be located in schemas prefixed with the name of the country associated with the data. Background data relevant to multiple countries will be located in the bg_general schema while, for example, background data specific to congo will be located in the bg_congo schema. Each country will have a schema for survey data to be uploaded into with the draft suffix. In this
example, we'll be uploading data to the congo_draft schema. Surveyors in Congo have read/write access to the congo_draft schema. Once layers have been reviewed and finalised by Rainforest Foundation UK, they will be moved from the _draft schema to the _approved schema. Surveyors in Congo have read only access to the congo_approved schema. 3. Select the layer v test_layer_001 and click Add The layer should now be loaded.
5. Uploading polygon data Polygons may be added to the PostGIS database for the External Actors, Livelihood Activities, Cultural Activities and Natural Features data types. It is assumed that GPS track data will be used to define a polygon in Quantum GIS which will then be uploaded to the PostGIS database. This is demonstrated in the following example where a track around a lake is used to define a polygon. A track can bee seen in the image above representing the shore of a lake. In order to import the lake into the PostGIS database, we must first create a polygon from the track which in currently a polyline. 1. Create a new shapefile by using the New Shapefile Layer button, 2. Ensure the shapefile is set to contain polygons and is in WGS84 Latitude/Longitude (EPSG code 4326).
If the table contains a text attribute called name, the contents of this attribute will be used to update the name of the feature in the PostGIS database. 3. Save the new shapefile in a sensible location. Next we must digitise the polygon representing the lake, using the track as a guide. Quantum GIS's snapping feature is very useful to ensure that the new polygon follows the surveyed shore of the lake. 4. Digitise the lake polygon and optionally, give it name by filling out the name attribute. The lake polygon should now look like this.
5. Save the polygon shapefile. With the polygon layer selected, the user should be able to upload the polygon to the PostGIS database as was done previously in the villages example.
6. Editing PostGIS Layer attributes Once features have been uploaded to the database, their extended attributes can be populated / edited. PostGIS layer attributes can be edited in the normal way in Quantum GIS using the Open Attribute Table button, Identify form., or through the Edit Feature form which is available through a right click on the The RFUK PostGIS Table Attribute Standard (version 008) lists a complete set of available attributes for each data type along with a human-readable description. 6.1 Enumerations Some attributes are set as enumerations. One example of this is the village layer's involved attribute. Enumerated types may only be set to one of a pre-defined set of values. In the above example, the village layer's involved attribute can only be set to one of the following values: UNSET (no value has been set yet) yes no The value of an enumerated attribute can either be typed in manually (it will have to be typed exactly), or can be set using one of Quantum GIS' advanced attribute editing features as described below. A full list of the enumerated types used in the RFUK PostGIS database can be found in the RFUK PostGIS Table Attribute Standard (version 008). 6.1.1 Enabling enumeration drop-down menus The following instructions describe how to make entering enumerated attribute values easier by enabling drop-down lists. 1. Open the layer's Layer Properties dialog 2. Select the Attributes tab 3. For each attribute with a type starting with enum_, change the edit widget from Line edit to Enumeration.
4. Click OK to close the Layer Properties dialog. Now when editing feature attributes, enumerated attributes can be populated using drop-down menus.
7. Deleting PostGIS Layers Layers in _draft schemas can be deleted using the PostGIS Manager plugin. Please treat this email as sensitive information as it contains the usernames and passwords for the surveyors (be aware of accidentally forwarding this or replies with quoted text to untrusted parties). I'm happy to announce that the beta version of the RFUK PostGIS Upload Plugin is now complete and I've set up a Quantum GIS python plugin repository for it on your VPS (hosting). The documentation (in english) is attached which explains how to install and use the plugin as well as how to access and modify data in the PostGIS database. I expected you might want to translate the docs into French so I've passed an editable version. I've also attached version 008 of the table attribute standard which has very slight modifications from the last one you sent to us (such as shortening some of the additional attribute names to 10 characters to stay in-line with the ESRI Shapefile standard). Feel free to start using the database to upload new survey information to the database. If, in a few weeks, once people have been using the plugin for their work, there are no reported problems, we can consider the plugin as a release (completed) version, rather than a beta version. The usernames and passwords for the surveyors are as follows: Cameroon remote_cameroon ofg3ctyg5h Central African Republic remote_car clorxiofr0 Congo remote_congo utzaysjbmk Democratic Republic of Congo remote_drc h2oxuzhc5x Gabon remote_gabon moz21o9obv
handjagt Bigbluesea77