jps services
  • Home Page
  • GIS Training Courses
    • QGIS Training Courses
    • ArcGIS Training Courses
    • MapInfo Pro Training Courses >
      • MapBasic Training Course
  • About
  • Blog

QGIS - Geoprocessing tools

6/5/2014

0 Comments

 
If you decide to use the geoprocessing tools within QGIS, you may find that certain fields within the attribute data are not valid because they are not correctly updated after you have completed the process. Take, for example, the following problem. You have a map of France which shows all the Departments within the country. This layer also contains an attribute data column relating to the Regions of France called code_regio containing the regional code. You would like to create a layer of the regions from the attribute data column code_regio which contains these regional codes.   We can use this data, which is within the Department layer's attribute table, to create our new regions layer by dissolving the relevant department polygons.
QGIS Geoprocessing Tools Option
QGIS Geoprocessing Tools Option
You can use the Dissolve tool within the Geoprocessing Tools option to dissolve the departmental polygons to create a new layer of regional polygons. You can access these tools from the top main menu under the Vector option.

Dissolve dialogue box
Dissolve dialogue box
Map of French Departments
Map of French Departments prior to Dissolve function
Map of French regions
Map of French regions created by using the Dissolve option
This option will create a layer which dissolves the relevant departments to create a regional layer map of France. However, as you can see by comparing the departments_obs and Department merged to Region attribute tables, the options for creating the regional map are currently limited to creating new polygons without the ability for all the relevant data within the attribute tables being correctly updated. 
Departmental attribute table
Departmental attribute table
The attribute table below shows the 21 names of the regions of France and the regions' codes. However, the other data has not been updated to reflect regional rather than departmental data. So how can we solve this problem if the current dissolve facility is only useful for creating the relevant regional polygons?
Attribute table of dissolved polygons
Attribute table of Departments merged to Regions
If you have used either MapInfo or ArcGIS you may be aware that you are able to create the appropriate regional polygons as well as specifying the updating of the additional attribute data from the departmental table. For example, both these software packages have the facility to sum field attribute data when dissolving polygons as a standard feature of the software. However, we can achieve similar functionality within QGIS if we use a PostGIS layer.
As the current option within the Geoprocessing tools only offers the facility to merge polygons without additionally updating other attribute fields, we could use the PostGIS method of achieving the required result if we need totals for any of the attribute fields. In the case of our French map we would like to update a field called nb_visits so that it accurately reflects the regional attribute table data. With the Dissolve function there is no option to update fields by totalling their values, however using a PostgreSQL database we can specify which fields we would like to have totalled when we create the new regional layer. Using an SQL statement we can create a new table called Regions which dissolves the appropriate departmental polygons from the departmental layer.  We can also obtain the correct totals for the regional visits from  the nb_visits field which has been renamed  as Visits.
SQL Editor dialogue box
SQL Editor
The original Department layer is a shapefile which can be converted to a PostgreSQL file with the PostGIS Shapefile loader. This option to convert shapefiles is available within the pgAdmin tool supplied with PostgreSQL. Once we have loaded the shapefile into the postgreSQL database we can make the appropriate query to create the PostGIS layer. This new Regional layer will take the code_regio attribute and create new polygons from the departmental polygons for each of the regions shown in the code_regio column.   Below is the attribute table for the new Regions layer.
Attribute table with correct totals for visits
Attribute table with correct totals in the visits field
Additionally, the query now provides a correct total of all the visits for each region. This functionality is available, as previously mentioned, within both MapInfo and ArcGIS without requiring this extra PostGIS step. However, the availability to use PostGIS layers within QGIS means that even complex queries can be handled.

If you would like to further explore how GIS could help your organisation jps services offers one and two day training courses in QGIS, ArcGIS and MapInfo. 
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    Author

    Joe Short BSc has been involved with various mapping solutions for over twenty years.  If you are considering implementing a GIS  or have ArcGIS Pro, MapInfo Pro or QGIS training requirements, jps services would be happy to be of assistance to your organisation. 

    Archives

    April 2020
    March 2020
    October 2019
    September 2019
    August 2019
    July 2019
    March 2019
    November 2018
    October 2018
    August 2018
    July 2018
    November 2017
    October 2017
    September 2017
    July 2017
    February 2017
    January 2017
    December 2016
    November 2016
    October 2016
    May 2016
    February 2016
    September 2015
    August 2015
    April 2015
    February 2015
    November 2014
    October 2014
    July 2014
    June 2014
    May 2014
    March 2014
    February 2014
    December 2013
    November 2013
    October 2013
    September 2013
    August 2013
    June 2013
    May 2013
    April 2013
    February 2013
    December 2012
    October 2012
    September 2012
    August 2012
    July 2012

    Categories

    All
    Arc Gis
    Arcview
    Autodesk
    Cad
    Gis Training
    Local Government
    Mapbasic
    Mapinfo
    Quantum Gis
    Relational Databases
    Saga Gis

    RSS Feed