0% found this document useful (0 votes)
66 views9 pages

QGIS - Working With Tables

The document discusses working with attribute tables in QGIS. It provides instructions on how to add, delete, and sort fields; select records; and add non-spatial data to spatial data by joining a spreadsheet. The exercises teach how to count fields and records, sort data, select features meeting criteria, and link attribute data to a shapefile using a spreadsheet as the source.

Uploaded by

Helios
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views9 pages

QGIS - Working With Tables

The document discusses working with attribute tables in QGIS. It provides instructions on how to add, delete, and sort fields; select records; and add non-spatial data to spatial data by joining a spreadsheet. The exercises teach how to count fields and records, sort data, select features meeting criteria, and link attribute data to a shapefile using a spreadsheet as the source.

Uploaded by

Helios
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

QGIS – Working with Tables

Objectives:

In this exercise, you will be able to learn how to:

 Add, delete, and sort a field in the attribute table.


 Selecting some records
 Add non-spatial data to spatial data

Note:
 The QGIS version used for this exercise is version 2.12.1 or the Lyon version. User
interface might have some differences with other versions of QGIS.
 A spreadsheet application is necessary. But, it is advisable to use Microsoft Excel. The
version used in creating this manual is MS Excel 2010 Professional Edition.
 There will be some questions that would require your answer. It would be appropriate that
you will carefully address those questions in order for you to be properly guided.

Dataset Required:
 You will need the qgis_tutorial_working_with_tables01 folder:
o that contained the cebu_city folder that contains:
 Shapefiles and its component files which are:
 BrgysOfCebuCity
 CebuCityBoundary
o The QGIS file, Population Study of Cebu City.qgs.
o The spreadsheet file, CebuCity_Pops.xlsx.

Discussion:
The Attribute Table

One type of data in Geographic Information System (GIS) is the attribute data. The attribute
data is the storage facility of information for a certain feature in a feature-class or shapefile.
It is designated non-spatial data when it is still separated or is not yet defined with a
relevant location or feature. The way that the attribute data is actually presented and
organized is what we called the attribute table. The attribute table is how the information
about the features in your shapefile is presented to the GIS user. For a GIS to be more
useful, a feature within a shapefile has to contain enough information for it to be processed.

Records and Fields

The attribute table is composed of rows and columns. The columns contain labels which
relate to the rows below it. The rows on the other hand, contain the individual data and
each of these rows corresponds to individual spatial features in a shapefile. A field is simply

Version: 01 – Edition: 01
1
the element in the table where labels are placed; simply, it is the column part. The record
on the other hand is the row of the table where actual individual data is stored.

Fields

Records

Starting up the QGIS application and opening the map project

o Start the QGIS Desktop application by clicking the provided shortcut icon or

from the Start Menu .

At the time QGIS ran, a splash window will appear (like the figure below). Just wait for it to complete and
disappear.

o When the QGIS Tips! window (as shown below)

Version: 01 – Edition: 01
2
appears, just click the OK button to close it, otherwise you may select

checkbox to prevent this window from appearing again


the next time you run the application.
o Click on the Project menu and select Open.

o In the Choose a QGIS project file to open window navigate and locate the QGIS project file
Population Study of Cebu City and click the Open button. (Hint: the file stated, is located
within the qgis_tutorial_working_with_tables01 folder)

Your data view should be more similar to the image below.

Version: 01 – Edition: 01
3
Opening the attribute table

o From the QGIS main window’s Layers Panel, right-click on BrgysOfCebuCity layer and select
Open Attribute Table.
1. How many records are in the attribute table? How many fields?

Fields:________ Records:__________

You can easily manually count the number of fields by using the fields’ labels. But when it comes to
records it would be difficult to do it manually. Don’t worry about it, because QGIS’ attribute table
includes on its title the number of records as shown below.

The numerical values right after the layer name is the number of rows contained in the layer as
designated by Features total, the number of filtered, and if selection happened, the number of
selected record or features as related. You can also access the field’s list through the Layer
Properties window – Fields tab.

o Still in the Attribute table window, click on the Toggle editing mode tool from the toolbar

to enable editing then click the New column tool.


o In the Add column window, provide the following:
 Name: BrgyCode
 Comment: Barangay Code
 Type: Text (string)
 Width: 20

Verify with the image below and click OK.

Version: 01 – Edition: 01
4
2. What is the default value that appeared on each row under the newly created field?
________________________________

Delete field

The field appear as Capital is not required or it not necessary. Therefore, you have to remove this
field. Make sure that editing is still active.

o In the Attribute table window’s toolbar, click the Delete column tool. In the Delete
Attribute window’ list, click on Capital then click OK.

Notice that the field Capital is now gone. Remember that as long as you don’t update the attribute
table, the removed field can still be recovered and so with all editions you have done.

o Delete the MUNIPOLS field as well.

Once you have done removing MUNIPOLS field, click on the Toggle editing mode again and save
the editing you have done.

Sorting fields and selecting records

Arranging the records (sorting) is useful to GIS users, because it is a way to get the ranking and order
of data or can also be a way to check the completeness of the data.

o Click on the AREA field.

The arrow/triangle that appears just above the field name designates how the data under are sorted
or arranged. When it is pointing upward, it is in ascending order (that is, from the smallest to the
largest value for numerical values, or from A to Z for alphabets).

3. What barangay in Cebu City that has the largest and the smallest are and how big or small is the
area?
a. The largest: _____________ - __________
b. The smallest: _____________ - ___________
o Click on the gray box that contained numbers on the left most side of the Barangay Suba row.
(Sort the BRGYPOLS first to easily locate Barangay Suba.)
o Scroll the table and locate Barangay Pasil. Press the CTRL button and without releasing it click on
the gray box for Pasil. Do the same with Parian.
o On the bottom portion of the attribute table window, click the Show All Features

and select Show Selected Features.


4. Describe what happened after the Show Selected Features was clicked.
___________________________________________________________

Version: 01 – Edition: 01
5
o Restore to Show All Features and click on the Unselect all tool on the toolbar to clear all
selections.

This time, you will select features or records by means of an expression.

o Click on the Select features using an expression tool. In the Select by expression window, expand
Fields and Values then double-click on COASTAL. Click on the = button, then click on all unique
button. Double-click the value 1 on the result list. Verify your expression with the figure below.

o Click on the Select button and then Close.


5. How many records have been selected? (You can use either to show only the selected features
or refer to the window’s title bar.)
_______________
o Clear all selections and close the attribute table window.

Adding data into the existing attribute table

Situations might arise that the provided data is not spatially referenced or perhaps due to limited
time perhaps, the collected or obtained data whenever added to an existing shapefile might either
destroy the attribute table or the data source. Recycle of data is also a necessity that the data
source can also be utilize to non-spatial processes or analysis. You might think that you have to
manually encode every data into an existing attribute table to accomplish this task. Fortunately, you
can link non-spatial data source to an existing spatial data by means of joining it. For this portion of
the exercise, our non-spatial data source is in a spreadsheet format (that is, can be opened using an
MS Excel application).

o Run the MS Excel application and open the excel file CebuCity_Pops.xlsx.
o In the MS Excel program, click on File and then Save As. In the Save As window, set the Save
as type: to CSV (Comma delimited) (*.csv) then click on Save. Refer to the following image
for confirmation.

If there is a compatibility warning message, just click on Yes. Close the MS Excel program.

o Back in QGIS main window, on its toolbar click on the Add Delimited Text Layer tool.
o In the Create a Layer from a Delimited Text File window, click on Browse. Locate the CSV
file you have created earlier and open it.

Version: 01 – Edition: 01
6
Discussion:
CSV is an acronym for comma-separated values. It is a file that stores tabular data
(numbers and text) in plain text format. Each line of the file is a data record. Each of the
record consists of one or more fields that is separated by commas, hence the name comma-
separated.

Notice how the fields in the Create a Layer from a Delimited Text File window are filled up.

o Make sure that the File format is in CSV (comma separated values) and Geometry
definition is No geometry (attribute only table).

Note:
Inspect the data and make sure that the numerical values do not contain any comma, like
the common numeric format that has comma separation. If this happen, modify the
contents of the excel file and set the numbers to general, that is, without any formatting.

o Click on OK.

Notice how the CSV non-spatial data is represented in the Layers Panel.

o Once again open the attribute table for the BrgysOfCebuCity layer (right-click on the layer).

o In the Attribute table window, click on the Open field calculator tool. In the Field
calculator window, check on Update existing field and in the dropdown-box just below it
locate and select BrgyCode. Expand the String group and double-click on upper function.
Expand this time the Field and Values group and double click on BRGYPOLS. Click on the

close parenthesis button and verify that your expression is similar with the image below
then click OK.

Take note of how the BrgyCode field is filled-up and make sure that it does not contain any null
value.

o Update the table by click on the Toggle editing mode tool. Close the Attribute table window.
o Right-click on the BrgysOfCebuCity layer once again and this time select Properties. In the

Layer Properties window, click on the Joins tab and click on the plus signed button . In the
Add vector join window, set the following parameters:
 Join layer: CebuCity_Pops

Version: 01 – Edition: 01
7
 Join field: Brgy_Code
 Target field: BrgyCode
 Cache join layer in virtual memory: checked
 Custom field name prefix: checked (accept the default name prefix)

Verify with the image below then click on OK.

o Click OK on the Layer Properties and open the attribute table for the BrgysOfCebuCity layer.

Notice how the data from your CSV are being linked to your existing attribute table and how the
field names of the linked table are renamed.

Map inquiry

At this point, you will make use of the available data and inquire for the population trend and
density. First, inquire for the most populated barangays from 1960 to 2000.

o In BrgysOfCebuCity attribute table, sort the field CebuCity_Pops_Population_1960 in


descending order. If in case the field name is not completely displayed, just place the mouse
cursor in between field names (that is, their boundary) until the mouse cursor will have a

double-arrow symbol and then double-click on it.


6. Write the down the most populated barangay in that year and how much.
_________________________
o Using the previous step, make inquiries for the most populated barangay in the year 1970, 1980,
1990, and 2000. Don’t forget to write down the number of respective population.
7. 1970: _________________
1980: _________________
1990: _________________
2000: _________________

Based on the result above, there is a specific barangay that consistently hold the most populated
barangay in Cebu City and that is barangay Guadalupe. In the population data of 1960, this barangay
is at the 6th position with a population of 8,188. It doubled its population for a decade.

Version: 01 – Edition: 01
8
o Still in the attribute table window, click on the Open field calculator tool. Under the Create a
new field checkbox (just keep it checked), type-in PD_1960 (PD here stands for Population
Density) in the Output field name textbox. Set the Output field type to Decimal number
(real) and the Output field width to 10 and Precision to 8.
o Expand the Fields and Values and double-click on CebuCity_Pops_Population_1960 then
click on / (or you can type it in directly on the expression box) and then double-click on AREA.
Make sure that your expression is: "CebuCity_Pops_Population_1960" / "AREA" then click OK.
o Click on the Toogle editing mode to update your attribute table.

Examine your attribute table focusing on the added field. What you just did is you have created a
field that will contain population density (that is, the number of population per unit area) and this
would tell us that for a specific year, there are larger areas that have less population and there are
also smaller areas that have more population. The larger the density value the denser the
population in that area and the more populated it is.

8. For the year 1960 does the most populated barangay is also the densest barangay? If not, then
what barangay would it be? _____________________

Population symbology

o Close the attribute table window.


o Open the properties window for BrgysOfCebuCity and click on the Style tab.

For the purpose of illustration, at this point, you will only use the 1960 data to display the
population for each barangay.

o Set the style to Graduated, the Column to PD_1960, and choose your preferred Color ramp
then set the Classes to 12. Click on Classify. Click on the Apply button and just move the Layer
Properties window aside so that you can see the data view. Change the Mode setting, click the
Apply button every time you make the change and observe how your data view display the map.
Choose the best Mode setting for you, and after you are satisfied, click on OK.

You can also use the other population years and create their corresponding density fields then
compare results with those years.

o Save your map project and close QGIS.

Version: 01 – Edition: 01
9

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy