Saturday, 25 April 2015

Querying the attribute table of a feature layer in QGIS

Overview of the task

In our earlier post we showed you how to join attribute data tables in a GIS using ArcMap 10.2.
For today’s exercise, we will be working with attribute data in QGIS and making a Selection by Attributes. Our data comprises a spatial layer of different point features digitized on a paper map of Ibadan municipality. These point features comprise of schools, churches and hospitals. A building repair survey was done in the area by the local authorities and we have section of that in a csv table – Building Repair Survey.

Task
  • Join the attribute data to the spatial layer. (In QGIS, we had to invent a runaround way by exporting the shape file out as csv, populating it in excel and returning back as a csv/shape file to QGIS).
  • Select on the map which point features where building color is blue.
Procedure
  1. Digitize the point features (places shape file) on the raster image. Right click on the layer and Save as
1
2. A Save vector dialog box will pop up. Change Format to CSV and save in your working folder under places.csv. Make sure you uncheck Add saved file to map.

2

Snippet of the Building Repair survey csv table. We are bringing in details to the places.csv file.In excel,  copy out the attribute column and rows from the building repair survey table and paste into the places.csv sheet.
3

3. When you paste the places.csv will look like this. The pasted contents are to the right beginning from column C.
4
  1. We will now return the places.csv table back to QGIS. Click on Create a layer from Delimited Text file and the dialog box will come up. Browse to where the places.csv file is and load it into QGIS.
5

5.       Put the proper coordinate reference system
5

6. You now have two identical spatial layers. Change the name of the new layer to placescsv so you don’t mix up the two. Remove the first layer –places.
7

7. To carry out the Selection by Attributes, we will need to build a query. Click on the Layer on the main menu, scroll down and select Query.
8

8. Our selection is “Building_col” = ‘blue’'. Double click on the field to be queried (Building_col), choose an operator (=) and take the value (blue) you are querying for. The message box gives the result.
9

9. Right Click on the layer- placescsv and open attribute table to view the rows selected from the Query.
10

Hope you enjoyed the post. Feel free to start practicing and send your comments.

No comments:

Post a Comment