Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

QGIS – Creating and Editing Vector Data

Objectives:

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

 Create a vector data by using an aerial photo.


 Edit an existing vector data by modifying polygon and point features.

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.
 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_creating_editing folder:
o that contained the cebu_city folder that contains:
 Shapefiles and its component files which are:
 BrgysOfCebuCity
 RiversInCebuCity
 RoadsInCebuCity
o that contained the philippine_typhoon_pablo folder that contains:
 Shapefiles and its component files which are:
 Lakes_in_Phil
 Philippine_Area_of_Responsibility
 PhilMap_NoPop
 PhilMap_NoPopEdited
 Typhoon_Pablo_Data
 Typhoon_Pablo_Data1
o The QGIS file, cebu_city_srp.qgs.
o The QGIS file, editing_vector_spatial_data.qgs.
o The bookmark file, central_cebu_area.xml.

Starting up the QGIS application and opening the Cebu City SRP map project

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

from the Start Menu .

Version: 01 – Edition: 01
1
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)

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.

In the Choose a QGIS project file to open window navigate and locate the QGIS project file
cebu_city_srp and click the Open button. (Hint: the file stated, is located within the
qgis_tutorial_creating_editing folder)

Version: 01 – Edition: 01
2
Your current data view should be similar to the following image.

Georeferencer

Note:
The Georeferencer is an extension plug-in. In order to make it available, you have to
access the plug-in repository through “Plug-ins\Manage and Install Plugin…” menu then
search or scroll down from the list for “Georeferencer GDAL”. Check the checkbox
beside the listed “Georeferencer GDAL” and then click on the “Close” button.

o In the QGIS main window, click on the Raster menu and select Georeferencer then click
Georeferencer.
o In the Georeferencer window, click on the File menu then Open Raster. Locate the image file
SRP_01 (hint: the file is located in qgis_tutorial_creating_editing folder). Set the filter option to
JPEG JFIF (*.jpg *.jpeg *.JPG *.JPEG). Once located, open it.

Your Georeferencer raster viewer should look similar to the image below.

Version: 01 – Edition: 01
3
o Click on the Zoom In tool and draw a box on the near left portion of the image as shown
below.

Make note of the yellow dot on the image. That will be a reference point that you will use to mark
the location on your basemap.

o Click on Add Point tool from the toolbar. While your cursor is in a cross-form , click
on the yellow-dotted element on the image. A window will pop-up. In the Enter map

coordinates window, click the From map canvas button.

QGIS main window will appear on your display.

o Using the scroller on your mouse device, zoom in to an area shown in the following image.

After you zoomed-in to that area, you will notice an intersection of road as shown below.

Version: 01 – Edition: 01
4
o Click on that meeting point of those lines.
o In the Enter map coordinates window, click OK.

Notice that you are now back to the Georeferencer window and the yellow-dotted element on the
image is now containing a red dot. The GCP table just below the viewer is now containing a single
row of information related to that point.

o Using your mouse-scroller zoom-out the image. Click on Zoom In tool and draw a box on the
right area of the image as below.

o With the zoomed-in view as below, perform the same operation as the point earlier and click on
the yellow dot. Do not forget to click the Add Point tool to accomplish this.
o In the QGIS main window, use the mouse-scroller to zoom-out and locate the portion on the
data view as shown below.

Version: 01 – Edition: 01
5
o Zoom-in on that area and click the tip of the extended most bottom portion of the box-like
feature. Refer to the image below.

o In the Enter map coordinates window, click OK.

Now the GCP table contains two rows.

o Click the Start Georeferencing tool. When a warning will appear, just confirm it and in the
Transformation settings window, set the following parameters:
 Transformation type: Linear
 Target SRS: Project CRS (EPSG: 25394 …
o Click the ellipses button beside the Output raster textbox. Locate a suitable storage
location (it would be recommended to store it in the location of the original image) and save it
with the name SRP_01_modified.

The default file type is GeoTIFF. It has file extension of tif.

o Check the Load in QGIS when done then click on OK.

o Click the Start Georeferencing tool again.


o Close the Georeferencer window and click on Save if necessary.

Version: 01 – Edition: 01
6
o In the Layers Panel, right-click on the SRP_01_modified layer and click Zoom to Layer.
o Drag the SRP_01_modified layer to the most bottom part of the list and observe on how the
image is aligned to your basemap. Refer to the image below.

o Restore it back to the top of the list.

Create a new polyline layer

o In the QGIS main window, click on the Layer menu and select Create Layer then New Shapefile

Layer…
o In the New Vector Layer set the parameters as below:
 Type: Line
 CRS: Project CRS (EPSG:25349 – Luzon 1911 / Philippines Zone IV)
 New attribute:
 Name: RoadName

Click on the Add to attributes list button to add the RoadName


field.

o Click on OK.
o In the qgis_tutorial_creating_editing folder, create a new folder and name it as
myOwnDatasets. Within that newly created folder, save the new shapefile with the name
SRP_Roads.

Notice that in the Layers Panel, SRP_Roads layer is now included.

o Move the SRP_Roads layer to the top of Layers Panel.

o While the SRP_Roads layer is selected, click on the Toggle Editing tool from the toolbar.

Version: 01 – Edition: 01
7
1. What happened on the SRP_Roads layer in the Layers Panel?

_______________________________

o Click on the Add Feature tool. Zoom-in on an area in the right side as shown in the image
below.

o Using the image, and while the mouse-cursor is in add-feature mode click on the portion of
the road where it emerged from underground.

After you made the click on that portion of the image, notice that a dash line appears as you move
your mouse-cursor as shown below.

o Use the center-click of your mouse, press on it and with a drag gesture (that is, continue
pressing the center button of the mouse while you move it) this is a way to pan the data view
without actually using the Pan Map tool. Release the center-mouse button to stop the panning
mode.
o Left-click for the next vertex location of the line. Be careful to follow the road feature of the
image until you reach the boundary of Talisay and Cebu City. Refer to the image below.

Version: 01 – Edition: 01
8
o Whenever you are done, right-click on the data view. The Feature Attributes window will
appear. Leave the id empty while RoadName must be Cebu South Coastal Road. Click on
OK.

Your data view should be similar to the image below.

o Again click on the Add Feature tool and draw the polyline similar to the image below.

Version: 01 – Edition: 01
9
o Open the attribute table for SRP_Roads layer.
2. How many records are there in the attribute table? ___________
o Close the attribute table.

o Using the selection tool click on the Cebu South Coastal Road to highlight it. Click the

Split Features tool and draw a line (left-click on the first point and left-click again on the
second point) that would split the highlighted line as shown below then right-click once done.

Observe how the line feature is now split.

o Open the attribute table for SRP_Roads layer again.


3. How many records are there in attribute table this time? __________
o Close the attribute table.
o Click on the Toogle Editing tool again and save the edition you have made.

o Click on the Deselect Features from All Layers tool to clear all selections.
o In the Layers Panel, right-click on the SRP_Roads layer and select Properties. In the Layer
Properties window, set the color to an appropriate one, change Width value to 0.5 and click OK.
o To clearly view your SRP_Roads layer on the data view, temporarily hide the
SRP_01_modified layer.

Version: 01 – Edition: 01
10
Create a new polygon layer

o Make sure that the image is visible, add another new layer. Set its type to Polygon. Make sure
that its CRS is the Project CRS. Specify an additional attribute with the name AreaName.
Remove id from the Attributes list by selecting it and clicking on the Remove attribute

button.
o Click on OK and save it in the folder where you saved your previously created shapefile and
name it SRP_Area.
o The same as what you did with SRP_Road, start the editing mode and click on the Add Feature
tool.

Note:
When you draw any polygon feature, make sure that the points you will make is continues
and you are not crisscrossing your path. Therefore, you have to follow a single direction. If
your path is in a clockwise direction, you have to continue that markings until you go back
to the starting point.

o Click on a certain edge if the SRP feature on the image. Left-click on every corner you will make.
Refer to the image below for the pattern.

o Once it is done, right-click anywhere on the data view and name the feature as SRP Land. Click
OK.

o Open the attribute table of the new layer and click on the Open field calculator tool. In the
Field calculator window, make sure that Create a new field is checked and set the following
inputs:
 Output field name: Area
 Output field type: Decimal number (real)
 Output field width: 10 Precision: 8

Version: 01 – Edition: 01
11
Expand the Geometry group and double-click on $area then click OK.

4. How much is the value of the Area for the SRP Land feature? __________
o Close the attribute table window.
o Right-click on the SRP_Area layer and click on Properties. In the Style tab, set the Layer
transparency to 75 then click OK.
o Using the selection tool, click on the SRP Land feature to highlight it. On the toolbar, click on

Add Ring tool. Trace the edges of the pond on the image as shown below and right-click
anywhere on the data view once done.

o Set the SRP_Area layer’s transparency back to 0 again. Clear all selections and open the
attribute table for this layer.
o Open the field calculator and perform the same procedure as you did earlier, but this time
choose Update existing field with the Area as the field to update. Following the same step
earlier, provide the same expression as before then click OK.
5. How much is the value of the Area for SRP Land this time? Do the numbers differ from the
previous value? _______________________
o Close the attribute table and stop the editing mode and save the layer.
o Hide the SRP_01_modified layer and reorder the layers so that the polylines layers will be on
top of any polygons.

Your data view should be similar as below, except for the symbology.

Version: 01 – Edition: 01
12
o Save your map project and close QGIS.

Creating a new province, the Zamboanga Sibugay

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
13
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
“editing_vector_spatial_data” and click the “Open” button. (Hint: the file stated, is located
within the “qgis_tutorial_creating_editing” folder)

Version: 01 – Edition: 01
14
Notice that there are 3 layers appeared on the “Layers Panel”. These are the spatial data that we will be
working on. For the first part of this exercise, you will create a new political boundary which does not
exist on this given map.

o Click on the “View” menu then select “Show Bookmarks”.

Note:
If the “Spatial Bookmarks Panel” list is empty do the following:
 Click on the “Export/Import Bookmarks” button and select “Import”.

 In the “Import Bookmarks” window, locate and select the “bookmark” XML file
which is stored in the “qgis_tutorial_creating_editing” folder. Then click “Open”.

o On the “Spatial Bookmarks Panel” (usually located just below the “Layers Panel), select the

“Zamboanga Peninsula” bookmark the click the “Zoom to bookmark” button.

After you click the “Zoom to bookmark” button, the data view automatically adjust the scale and focus
to the location of Zamboanga Peninsula. As you will notice, there is no Zamboanga Sibugay yet in the
map, and that’s what you are going to create.

o Select “PhilMap_NoPop” layer in the “Layers Panel” then click the “Identify Features” tool.
In the data view, click on the lower portion of Zamboanga Peninsula.

This time a selection is made on that are you have just selected as shown below.

At the same time, another docked toolbox window appeared on the left side panel of QGIS. The window
is the “Identify Results”.

Version: 01 – Edition: 01
15
The “Identify Results” lists down the record that are stored in the attribute table related to the feature
you’ve just selected.

6. What is the name of the province (i.e. PROVINCE field)? ________________________

o Close the “Identify Results” window.

o In order to clear the highlighted feature on the data view, just click the “Pan Map” tool.

o In the “Layers Panel” select the layer “PhilMap_NoPop”. Then click on the “Toggle Editing”
tool.

Notice that in your data view the polygon features do have X marks. These X marks are the vertices of
the polygons. You can modify the shape of the polygons by moving these marks.

o Move the mouse cursor within the data view and observe the values beside the “Coordinate:”
label.

The values that appear next to the “Coordinate:” label is the current position of the mouse cursor within
the data view and it is dependent to the coordinate system applied to that layer or to the map project. It
is in Cartesian coordinate format, where the first number designates the x position (that is, the

Version: 01 – Edition: 01
16
horizontal or longitude) and the second number (as separated by comma) is the y position (that is, the
vertical or latitude).

o Now, move the mouse cursor until the coordinate value is more or less 122.907, 7.948.

If your mouse cursor is at the location stated above, that will be the first point where the path of the
cutting tool will follow.

Note:
From this point, you have to make sure that the “Advanced Digitizing Toolbar” is
available, as shown:

If they are not available you can make them visible by right-clicking on the empty
portion of the toolbar and mark “Advanced Digitizing Toolbar” under the “Toolbars”
category.

o From the “Spatial Bookmarks Panel”, select the “First Set” and click on the “Zoom to bookmark”
button. The map should be closely resembles to the following.

o From the toolbar, click on the “Split Features” tool. (Make sure that it is not the “Split
Parts” tool, you can verify the tool by placing the mouse cursor over the tool and wait for the
description to appear.)
o While the “Split Features” is active, move the mouse cursor on the data view and locate the
coordinates that you used earlier (i.e., 122.907, 7.948) and press-then-release the left-mouse
button (lift-click). Now move the mouse cursor.

Notice that a dash-line is now following your mouse cursor with its other end on the location where you
clicked the mouse.

Version: 01 – Edition: 01
17
o Locate the coordinates: 122.919, 7.923 and then press-then-release the left-mouse button (lift-
click). From the given list below, perform the same procedure until the last coordinate.
 122.917, 7.829
 122.997, 7.825
 123.003, 7.810
 123.020, 7.811
 123.024, 7.821
 123.082, 7.816
 123.097, 7.720

Every coordinates appear above are the vertices of the line you have just drawn. Your data view should
look closely like below.

o Press-then-release the right-mouse button (right-click) anywhere on the data view. Your data
view will be as the following.

o In the “Spatial Bookmarks Panel”, select “Second Set” and click the “Zoom to bookmark” button.
o The same as what you did on the first set of coordinates perform the same procedure with the
provided coordinates.
 122.342, 7.467

Version: 01 – Edition: 01
18
 122.194, 7.467

Your data view should look more like the image below:

o In the toolbar, click the “Save Layer Edits” tool.


o In the “Spatial Bookmarks Panel”, select the “Zamboanga Peninsula” and then zoom on it.

o Using the “Identify Features” tool, click on the newly created polygon feature.

Notice from the “Identify Results” window, the PROVINCE is still Zamboanga del Sur (encoded as:
Zamboanga_del_Sur). Aside from the polygon produced by cutting Zamboanga del Sur, an island just
below it has to be included in order to establish the Zamboanga Sibugay province.

o Close the “Identify Results” and click the “Pan Map” tool.
o From the “Layers Panel”, right-click on the “PhilMap_NoPop” layer and select “Open Attribute
Table”.

This time, the “Attribute table” window appears. On its title bar are the texts that show the layer name,
total features, filtered, and selected. There is also a toolbar which contains some tool for the attribute

Version: 01 – Edition: 01
19
table; you can check its name by placing your mouse cursor over it. Still the “Toggle edit mode” is active
and you can verify that by checking the background of the icon.

o Click on the “PROVINCE” field name to sort the fields below it. You make click on it many times
until it will be sorted in descending order (that is, Zamboanga del Sur will be on top and there
should be 4 records of Zamboanga del Sur).
o On the left-most portion of the table, you should see some numerical values. Click on those
numbers one by one and observe that the entire row (that is, the record) is selected. You may
transfer back to the QGIS main window to check the corresponding feature(s) of the selected
record.

At the point you selected a record that highlights a larger island (just below the new polygon) there are
other islands that are highlighted with it. In order to see it more clearly, just zoom it in. Since the island
that will be a part of Zamboanga Sibugay is just the one that is below it while the rest will still be part of
Zamboanga del Sur, therefore, we have to separate the islands.

o Make sure that the record related to the islands is still selected and highlighted in data view,

click on the “Split Feature(s) Part” tool.

Note:
“Split Feature(s) Part” is an extension that is included in the “Multipart Split” plugin. So,
in order to make it appear in the toolbar, you first have to install the “Multipart Split”
plugin. Refer to the exercise titled, “QGIS – Installing Plugins Online/Offline” on how to
install plugins in QGIS.

Notice that on the top portion of the data view are some texts the displayed the success of the
operation and how many features were created out of it, as show below.

o Switch back to the “Attribute table” window and observe that there are more records of
Zamboanga del Sur. Again, click each numbers on the left-most part of the table and switch
between QGIS and the attribute table to check each corresponding feature.
o From the toolbar in QGIS main window, click on the “Select Feature(s)” selection tool.

Click on the new polygon and while pressing the CTRL key click on
the second polygon (that is, the island just below it). Refer to the image below.

Version: 01 – Edition: 01
20
o In the QGIS main window, click the “Merge Selected Features” tool. In the “Merge features
attributes” window, click “OK”.
o Again, click the “Select Feature(s)” selection tool and select the just merged features.

7. What have you observed about the selected feature?

______________________________________________________________________________

o Switch back to the attribute table window and locate the selected record/row. On the selected
record, double click on the cell under the “PROVINCE” field/column and replace the content
with “Zamboang_Sibugay” (do not include the double-quote). Press ENTER key to end the
encoding.

Notice that there are “Zamboanga_del_Sur” records in the table. In order to unify the different
Zamboanga_del_Sur records, you have to merge all of them.

o By clicking on the numbers on the left-most side of the table, select each record. (Press the CTRL
key for each succeeding selections.) The table should be similar as below.

o Switch to QGIS main window and click on the “Merge Selected Features” tool.

Version: 01 – Edition: 01
21
o On the “Merge feature attributes” window, click “OK”.
o Switch back to the attribute table and observe that there is only one Zamboanga del Sur record
in the table. Sort the PROVINCE field in descending order to view the records clearly.

Recalculate the Area

8. How much is the value under the Shape_Area field for:


a. Zamboanga del Sur: ___________________
b. Zamboanga Sibugay: ___________________

From the attribute table, notice that the values under the Shape_Area field that corresponds to
Zamboanga del Sur and Zamboanga Sibugay are the same. Since you modified the political boundary of
each provinces it is will be suitable to recalculate their respective areas.

o Still in the attribute table, select both Zamboanga del Sur and Zamboanga Sibugay record (use

the CTRL key to select the succeeding record). Click the “Open field calculator” tool from the
attribute table toolbar.
o Make sure that the “Field calculator” window shows the “Only update 2 selected features” and
is marked. Select “Update existing field”. From the dropdown-box, select Shape_Area.
o Just below the “Search” box, expand “Geometry” and double-click “$area”. Verify that the
expression box only contained $area and the same as the following, then click “OK”.

This time the values under the Shape_Area field should now be changed.

9. What are the new values under the Shape_Area field for:
c. Zamboanga del Sur: _____________________
d. Zamboanga Sibugay: _____________________

Version: 01 – Edition: 01
22
o Close the attribute table window and in the QGIS main window’ toolbar, click the “Deselect

Features from All Layers” tool. Click the “Toggle Editing” tool and click “Save” in the
“Stop editing” window.
o From the “Spatial Bookmarks Panel”, select “Zamboanga Peninsula” and zoom-to-bookmark.

Your final output in the data view should looks like the image below.

Modifying Typhoon Pablo Track

For this portion of the exercise, you will be exposed in correcting a spatially dislocated features and
attributes. The path of the typhoon is represented in the map as points. These points contained in its
attribute table, the coordinates of the point, its speed, and the date it was taken.

o In the QGIS toolbar, click “Zoom Full” tool. Notice that there are points in the data view that
are not following the supposed path of the typhoon.
o Select “Typhoon_Pablo_Data” in the “Layers Panel”. Click on the “Toggle Editing” and “Identify
Features” tools and select the point feature in the coordinate 119.25, 12.16 (refer to the
coordinate value at the bottom of the window). Take note of the “Longitude_” and “Latitude_L”
values in the “Identify Results” window.

Version: 01 – Edition: 01
23
o Click on the “Move Feature(s)” tool and drag the point feature towards the coordinate stated in
the “Identify Results”.
o Perform the same steps with the other point feature as shown below.

Adding New Point Feature

o Open the attribute table for the “Typhoon_Pablo_Data” layer and take note of the total number
of features. Then close the attribute table window.

o Click on the “Add Feature” tool. By carefully monitoring the coordinate value, move your
mouse cursor until the value is 118.6, 11.2 then click the mouse.
o On the “Feature Attributes” window, type the following:
 Longitude_: 118.6
 Latitude_L: 11.2
 Speed: 120
 Date_Taken: 2012-12-05
Verify the values as below then click “OK”.

Version: 01 – Edition: 01
24
o The same as what you did earlier, perform the same operation and add the following point
features:
Longitude_ Latitude_L Speed Date
116.6 12.5 141 2012-12-06
120.8 10.1 140 2012-12-05
124.7 8.4 194 2012-12-05

o Again, open the attribute table for the “Typhoon_Pablo_Data” layer and examine the total
number of features. Close the attribute table and turn the editing mode off (click the “Toggle
Editing” tool) and save the updated layer.

o Update the map project by clicking “Save” . Exit QGIS.

Version: 01 – Edition: 01
25

You might also like