You are on page 1of 15

Practical Exercise 6

Vector Analysis

Department of Physical Geography and Ecosystems


Analysis, and GIS Centre at Lund University, Sweden

Introduction to Geographical Information Systems

GISA01
Vector Analysis

6 Vector Analysis

6.1. Purpose
The aim of this exercise is to provide you with an introduction to vector analysis and
attribute handling. More specifically you will learn:
- About different kinds of selection methods to select polygon, line or point features.
- How to structure and combine spatial queries.
- How to perform a simple overlay.
- How to select features by graphics.
You will assist a fictional a French family named Renoir to plan their summer holiday in
Scania, in southern Sweden. The Renoir family consists of a mother and father with two
kids and a dog. With them, they have bicycles and canoes, which they would prefer to
use during their stay.

6.2. Data
In Moodle, you can find a zip-file with the name DATA6_Vector_Analysis. Download
and save the file to your computer and use WinZip to unzip the files. The unzipped files
contain the following data:
Borders Shapefile: .shp, .dbf, .shx, .avl.
Castle Excel file: .xls.
Nature_reserves Shapefile: .shp, .dbf, .shx, .avl.
Hotels Shapefile: .shp, .dbf, .shx, .avl.
Lakes Shapefile: .shp, .dbf, .shx, .avl.
Roads Shapefile: .shp, .dbf, .shx, .avl.
Watercourse Shapefile: .shp, .dbf, .shx, .avl.
Create a folder in your local working directory with the name 6_Vector_Analysis (e.g.
C:\GISA01\Practical\6_Vector_Analysis). It is recommended that you keep an organized
file structure on your computer.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 1
Vector Analysis

6.3. Background
You have previously learnt how to select features interactively (point and click) and by
using SQL-queries. In this exercise you will also learn how to select features based on
their location relative to other features, known as a spatial query.
There are a variety of selection methods available and some of the more common
selection methods will be briefly described in this section. However, you can learn more
about the different spatial selection methods in ArcGIS Desktop Help. In the images that
follow, features colored black represent the input layer, grey features represent the source
layer and light blue features represent the output of the selection method.

Are crossed by the outline of


This method selects features in a line or polygon input layer that cross the boundary of
features in a line or polygon source layer. For example, selecting roads crossed by the
outline of nature reserves will select road segments that cross the boundary of the nature
reserves. If there for instance is a road segment within a nature reserve that does not cross
its boundary it will not be selected.

Intersect
This method selects features that share common parts with features in the source layer. If
we use the same example as above, road segments within nature reserves will also be
selected.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 2
Vector Analysis

Are completely within


This method selects features in the input layer that fall completely inside polygon
features in the source layer. If we once again use the example with nature reserves and
roads, only road segments completely within nature reserves will be selected.

Are within a distance of


This method selects features within a specified buffer distance from one or several
features. For instance, imagine that you have a layer containing locations of a number of
polluted and non-polluted wells. By using this selection method you can find non-
polluted wells that are located within a distance of 1 km from polluted wells.

Contain
This method selects features in the input layer that contain the features of the source
layer. For instance, you can select nature reserves that have lakes within them. Thus,
nature reserves that do not enclose a lake will not be selected.

Completely contain
This method is used to select polygons in the input layer that completely enclose polygon
features in the source layer. This method differs from Contain in that the boundaries of
the input features cannot touch the source features.

Share a line segment with


This method selects features in a line or polygon input layer that share line segments with
a line or polygon source layer. Two features are considered sharing a line segment if they

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 3
Vector Analysis

have at least two contiguous vertices in common. Features will not be selected if they
simply just cross.

Touch the boundary of


This method selects lines or polygons that share vertices or nodes with lines or polygons
in the source layer. Features will not be selected if they simply just cross.

Are identical to
This method selects any feature having the same geometry as a feature of another layer.
The feature types must be the same. For example, you use polygons to select polygons,
lines to select lines, and points to select points.

Have their center in


This method selects polygon features in the input layer that have their geometric center
within the polygon features in the source layer.

6.4. Answers to be sent to teachers


All students have to send answers for questions 6.1 6.5 by email to the teachers as
indicated in the document Sending Answers to Teachers available in the section Course
Information on the course homepage.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 4
Vector Analysis

6.5. Method

6.5.1. Locating suitable hotels


The first step will be to locate suitable accommodations for the Renoir family. The family
would like to spend three days in Scania. Since they will be travelling from the north of
Sweden, heading south, they would like to live in the most northerly hotel on their first
night and the most southerly hotel on their last night. The hotels should accept dogs and
should be located within walking distance from the beach or seaside.
- Start ArcMap. Choose to open a blank map document and save it as
scania_vector_analysis.
- Add the shapefiles Borders and Hotels. Ignore the message telling you that one
or more layers are missing spatial reference information.
- Set the map and display units to meters (View > Data Frame Properties, tab
General).
- Open the attribute table of the layer Hotels (right click on Hotels in the Table of
Contents (TOC) and choose Open Attribute Table) and study its attributes.
- Think on how your query to find suitable hotels should be structured. The hotel
should accept pets and be located within walking distance from the beach.
- In Attributes of hotels click Options and choose Select By Attributes.
- In the dialog window Select By Attributes click the fields, operators and values
and create the following SQL query:

PETS = Yes AND BEACH_M <= 1000

- Finalize by clicking Apply.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 5
Vector Analysis

Question 6.1: Which hotels accept pets and are within a distance of 1000m from a
beach?

6.5.2. Locating water suitable for canoeing

6.5.2.1. Finding suitable watercourses


The family will choose to stay at the hotel in Nasum on their first night (the most
northerly situated hotel of the ones that fulfill the criteria recently specified). The
following day, they would like to do some canoeing. More specifically, they would like
to canoe in a watercourse which ends in a lake. The watercourse and the lake must not be
further away than 30 km from the hotel in Nasum. You will therefore help the family to
find these suitable lakes and watercourses.
- Clear any selected features (Selection > Clear Selected Features or in the
Tools toolbar) then load the layer Watercourse, open and study its attribute
table and then locate the field named KOD.
Every object in the layer Watercourses consists of a line segment, and each line segment
has a code comprised of a capital letter and a number in the field named KOD. These
codes or rather classification scheme was developed by the Swedish Hydrology and

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 6
Vector Analysis

Meteorology Institute (SMHI). Several features or line segments make up one


watercourse and each watercourse has a drainage basin. The size of the drainage basin is
specified by the letter in KOD. The letter A represents the largest drainage basin size
whereas the letter H represents the smallest. The numbers are used to describe the
relative width of each feature or watercourse for graphical reproduction. Near the upper
portions of the basin, the watercourses are in general narrow (high number) and then
increase in size (lower numbers) as they approach the outflow. The following table shows
the existing combinations:

Line segment

Wide Narrow

A (Largest) A1 A2 A3 A4 A6 A6 A7 A8

B B3 B4 B6 B6 B7 B8

C C4 C6 C6 C7 C8

D D6 D6 D7 D8

E E6 E6 E7 E8

F F6 F7 F8
Drainage basin

G G7 G8

H (Smallest) H7 H8

Now, you want to select features that are based on the letters A to F in combination with
numbers from 1 to 6. This can be done by implementing a text search. However, since it
for the most part is easier base selections in ArcGIS on numeric fields you will to use the
field RODK instead. The field RODK is basically a numerical representation of the codes
in the field KOD and features that are based on the letters A to F in combination with
numbers from 1 to 6 in KOD all have numbers that are less than or equal to 206 in
RODK.
- Use Select By Attributes to select features in Watercourse where the numbers in
RODK are less than or equal to 206. Check the amount of features selected in
the attribute table. The selection should result in 380 selected features.
Close Select By Attributes and the attribute table and save your selection as a separate
shapefile (right click on Watercourse in the TOC and choose Data > Export Data).

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 7
Vector Analysis

- In the Export Data dialog window, choose to export selected features. Give
your new shapefile the name suitable_watercourses, save it with the rest of
your data and choose to add it to the map.
- Uncheck Watercourse in the TOC in order to only see the suitable watercourses
in Suitable_watercourses.
Now you are finished with the first criterion, locating watercourses that are wide enough
for canoeing. The other criteria were that the watercourse should end up in a lake and be
within 30 km of the hotel in Nasum. This means that you will have to search for features
based on their spatial relationship with other features.

6.5.2.2. Finding suitable lakes


- Add the layer Lakes and in the main menu click Selection > Select by location.
The Select By Location dialog window will appear.
The procedure is done in a logical way through a sentence stating how the selection
process is to be carried out. You will now perform a couple of selections. The first one to
select lakes that are connected to suitable watercourse and the second one to select lakes
from the first selection that are within a distance of 30 km from the hotel in Nasum. Make
sure to have the attribute table of Lakes open so that you can observe the amount of
features selected during the selection procedure.
- In the first drop down menu in Select By Location choose Select features from
and in the box The following layer(s) check Lakes.
- In the drop down menu That choose Touch the boundary of and in the drop
down menu The features in this layer choose Suitable_watercourses. Finalize
by clicking Apply.
- So basically the selection should read I want to select features from the
following layer lakes that touch the boundary of the features in the layer
Suitable_watercourses.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 8
Vector Analysis

Note: Alternatively you can also specify a spatial query that reads: I want to
select features from the following layer lakes that are within distance of the
features in the layer Suitable_watercourses. Apply a buffer to the features in
Suitable_watercourses of 0 m.

The last step is to select the lakes from the current selection that are within a maximum
distance of 30 km from the hotel in Nasum where the family will stay on their first night,
so do not clear the previous selection! Once again make sure to have the attribute table of
Lakes open to keep track on how many features that are, and are to be, selected.
- Open the attribute table of Hotels and select the hotel with the name Nasum.
Close the attribute table of Hotels.
- Use Select By Location to find all of the currently selected lakes that are within
a distance of 30 km from the hotel Nasum.
- In the first drop down menu in Select By Location choose Select from the
currently selected features in and in the box The following layer(s) make sure
Lakes is checked.
- Select features that are within a distance of 30 km from Nasum in the layer
Hotels. This time, you will have to check the box Use selected features to only
calculate distances from Nasum.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 9
Vector Analysis

Note: When you select features based on another selection, the results might
sometimes not show as expected in the map display window. For instance,
lakes can appear selected although they are not. If this happens, clicking Full
Extent in the tools toolbar might update the selection in the map display
window. However, you can always trust the attribute table, as the amount of
records shown as selected there will always appear correct.

Question 6.2: How many lakes are suitable for the Renoir family?

- Export the selection as a new shapefile through using Export Data and save it
as suitable_lakes.
- Click Selection > Clear Selection.
- In the Tools toolbar click Measure and make sure that the features in the
layer Suitable_lakes really are within a distance of 30 km from Nasum.
What you just did was to combine queries. By combining queries you can perform more
complex searches and refine selections by using either Select by Location or Select by
Attributes.

6.5.3. Locating roads and nature reserves for cycling


After canoeing, the Renoirs would like to spend the second night in the hotel Havang
located in a beautiful part of Scania called Osterlen, ideal for a pleasant bike trip. The
Renoirs want to cycle in a nature reserve not too far from the hotel and they want to know
which roads that intersect a nature reserve in order to plan their trip. Your aim is to find
out the total length of all the roads intersecting the nature reserve that are within a
distance of 30 km from the hotel Havang.
- In the TOC, choose to only draw the layer Borders and Hotels in the map
display window and then add the themes Nature_reserve and Roads.
- First off, use Select By Location and apply a spatial query that selects all roads
that go through a nature reserve (Intersect).
- Open the attribute table for Hotels and select Havang.
- Perform a spatial search to select roads from the current selection that are
within a distance of 30 km of the selected hotel.
- Export the selection as a new shapefile through using Export Data and save it
as suitable_roads.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 1
Vector Analysis

- Find out the total length for of all of the suitable roads. Right click the header of
the relevant field in the attribute table of Suitable_roads and choose Statistics
(unit is meters).

Question 6.3: What is the total length (in km) of all the roads that pass through the
nature reserve near Havang?

6.5.4. Performing an overlay in ArcToolbox


- Right click Suitable_roads in the TOC and select Zoom To Layer.
If you take a closer look at the roads that intersect the nature reserve you might notice
that parts of the line segments representing the roads are not completely inside nature
reserves, however, they do intersect them. If you want to calculate the length of the parts
of road segments that are only within the nature reserves you must cut the lines so that
they only exist within the polygon. To do this you must perform a line-in-polygon
overlay using ArcToolbox. ArcToolbox is where you can find, manage, and execute
useful geoprocessing tools.
- Activate ArcToolbox by clicking Window > ArcToolbox or in the Standard
toolbar.
- In ArcToolbox click Analysis Tools > Overlay and double click Intersect.
- In the drop down menu Input Features choose Suitable_roads and then
Nature_reserves. Make sure to save the output in the correct folder give it the
name suitable_roads_intersect and click OK.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 2
Vector Analysis

Check your results. The roads have now basically been cut and the output layer should
only contain segments of roads that are actually within the nature reserve.
- Open the attribute table to the layer Suitable_roads_intersect.
- If you compare the values of length with the ones in the layer Suitable_roads
you might notice that the values have not changed.
- In the attribute table for Suitable_roads_intersect right click the heading for the
field LENGTH, choose to Calculate Geometry (if you get a warning message,
ignore it) and then click OK to calculate new lengths for the line segments.
- Find the total length of the roads within the nature reserve in the same way as
before by using Statistics.

Question 6.4: What is the total length (in km) of all the roads within the nature
reserves near Havang?

6.5.5. Castle excursion


For their last night in Scania, the Renoirs would like to stay at the hotel Smygehuk. They
want to look at castles in the southwest of Scania and meanwhile have lunch at one of
these castles.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 3
Vector Analysis

You currently have no map layer with castles. However, all the relevant information to
create such a layer is located in the Excel file Castle.
- Add the Excel file Castle in ArcMap and open and explore its contents.
- Right click Castle$ in the TOC and choose Display XY Data.
- In the Display XY Data dialog window make sure that x and y are selected in
their respective X and Y Field drop down menu and click OK.
Observe that a new temporary layer is added to the TOC with the name Castle$ Events.
We need to export the event layer as a shapefile in order to make selections on it.
- Right click Castle$ Events and choose Data > Export Data. Give it the name
castles, save it with the rest of your data and choose to add it to your map.
- Use Select By Attributes to select castles with a restaurant (not caf) and save
your selection as a new shapefile with the name suitable_castles.
Now, you could choose to select castles in the southwest part of Scania manually. But
just to demonstrate you will select castles with the use of graphics.
- First off, if it is not yet activated activate the Draw toolbar by clicking View >
Toolbars > Draw.

- Choose to draw a rectangle anywhere in the map display window by using the
New Rectangle tool available in the Draw toolbar.
- Right click your newly drawn rectangle and choose Properties and select the
tab Size and Position.
- Click the top left Anchor Point and enter 1308000 in the box X and 6181000 in
Y. Then in Size enter a Width of 75000 and a Height of 50000. Click Apply and
then select the tab Symbol.
- At Fill color select No Color and set the Outline width to 2. Click OK.

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 4
Vector Analysis

You will now make a selection by graphics based on the graphic filter that you have just
created.
- Click Selection > Set Selectable Layers and uncheck all layers except
Suitable_castles. Then, with your filter activated or selected, choose Select by
Graphics, under Selection in the main menu.
Castles that have a restaurant and are within the graphic filter should now have been
selected.

Question 6.5: What are the names of the castles that have a restaurant (not caf)
and are situated within the graphic filter?

End of Practical Exercise 6

Send your answers to the teacher as instructed

28-01-2010 Copyright 2010. Lund University GIS Centre. All rights reserved. 5

You might also like