By David Crowther
I recently ran a number of QGIS training courses and in many of the sessions we have started to explore Data Maintenance techniques. Many delegates have used other proprietary GIS software, such as MapInfo or ArcGIS and either wish to know how to undertake these Data Maintenance tasks within QGIS, or have common misconceptions related to past file structure restrictions which are limiting the benefits they can now derive from attribute data within QGIS.
In this blog, we will explore some simple techniques, plugins and tools available within QGIS in order to undertake your day to day Data Maintenance. These include editing Table Structures, Updating Columns, Attribute and Spatial Joins. We will use two GIS files, one showing the Lower Super Output Areas (Lsoa’s) and another the Bus Stops in Ashfield.
QGIS provides the interoperability to open multiple sources of geographic information and indeed doesn’t have the limitations that some proprietary GIS software have when it comes to amending the table structure of your GIS files. In this example, we will look at editing the table structure of an ESRI Shapefile, renaming, deleting, re-ordering and adding columns to our data. Below is the current data structure for the LSOA’s.
Using the QGIS Plugin – Table Manager – QGIS allows you to edit the structure of all your GIS files, including MapInfo TAB and ESRI Shapefiles. Having loaded the QGIS Plugin, open the Table Manager from the Vector Menu:
If you now select one of the current Columns, the options on the right now update to provide the capability to Move fields up and down, rename, clone, delete and add columns. In this example, we will simply add a new field called Area.
Use the Insert Field menu to choose the name, type and position for the new field.
Having Saved the changes, the new Area field has now been added and the column has Null values.
QGIS provides a Field Calculator which you can use to update data within your GIS files. In this example the options below, will extract the geographic area for the LSOA polygons.
The Area values will be extracted using the Area Measurements Units as defined within the Project Properties. Therefore, change the Units defined for the Area Measurements to update your data in square hectares, acres etc…
Another common GIS data management task is the ability to update one table using the values from a field another table. In this example, we will use the LSOA – LSOA Code field to update the Ashfield Bus Stops table with the LSOA code that each Bus Stop is within.
The Layer Properties menu allows you to JOIN tables together. However, as per the image below, there is currently no textual/attribute join between the Ashfield LSOA’s and the Bus Stops.
However, QGIS has an option to join datasets using their spatial location. From the Vector menu choose > Data Management > Join Attributes by location. Choose the Target layer to be the Bus Stops (as we are joining data to this layer) and the Join layer to the be the LSOA’s. Choose the geographic relationship to the where the Bus Stops are Within the LSOA’s and press Run.
The results of the Join will mean all of the fields from the LSOA table are now appended to each of the Bus Stop record. Which means we now know which LSOA or Ward Name each Bus Stop is in.
The final Data Management task we will explore utilises the full power of GIS software, this time to provide a count of Bus Stops within each LSOA polygon. This is a common task frequently applied to count incidents within geographic areas, for examples crime counts.
From the Vector menu choose > Analysis Tools > Count Points in Polygon. Choose the Polygon Layer to be LSOA and the Points Layer to be Bus Stops. Edit the name of the output Count field, and choose a name and location for the new output layer.
The LSOA polygon table now has a new column containing the count of Bus Stops that fall within that area:
Which we can then use to generate a thematic map showing areas with high and low counts.
Try exploring these common Data Management Tasks for yourself, using your own spatial file formats and see just how easy it is to transition from proprietary software to start managing and working with your spatial data within an Open Source application!