You are on page 1of 15

Geographic Information System and Remote Sensing Research and Training Centre (CGIS)

University Avenue P.O. Box 212 Huye - Rwanda;







1
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)

Exercise 4: Querying spatial data

Learning objectives


Participant who complete this exercise will be able to: select feature by location and by
attribute and to prepare data for analysis

1. Before you begin

The data for this exercise is contained in the following folder: GISData

2. Selecting by location

In Selecting features by location , you selected features according to their attribute values
In this exercise youll select features by location, that is, according to their spatial
relationship to other features, whether in another layer or in the same layer.
The spatial relationships that can be used are Distance, Containment, Intersection and
Adjacency.

To select features by location, you specify a selection method, a selection layer, a spatial
relationship, a reference layer, and sometimes a distance buffer. For this exercise we would
like to know the schools which are within a distance of 500 metres away from the Roads. To
do this you have to go through the following steps:

Open ArcMap as new map document
Upload data ( Province, District, sector, schools 2008, roads, lakes, Kivu, Idjwi,
parks) from the following folder :GISdata
Organize layers in logical order as follows:



Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





2
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)



Selection menu and click Select By Location


In Select By Location dialog box, check the following :
I want to : select features from
The following layers : Rwanda Schools
That : are within a distance of 50 m
The features in this layer : Roads
Apply




Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





3
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)



In the ArcMap window you find the information that 182 schools which are at 50 m
from the road have been selected.




Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





4
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)
We are interested now only in those shools which are not only 50 m away from the
roads but also only in a 5000 meters distance to the parks.
Change the settings to Choose (I want to) add to the currently selected features and
select the layer schools(that :) are within a distance of the features in this layer: Parks
Uncheck the option Use selected features.





Question: How many schools that are at 5 km from the parks?: ..........

3. Selecting features by Attribute

- Selection menu Select By Attributes.
- Choose as Method create a new selection.
- Now you will define a query which gives the number of all schools that are in Kigali
City

From selection menu, click on Select By attributes and check the following:
Layer: Rwanda schools
Check only show selectable layers in the first list
Method: Create new selection
Double click on Province
Click on Equal
Click on get unique value
Province=Kigali City


Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





5
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)
Ok







What was the total number of those schools ? ( 73-1)=72 One of the school is outside
Kigali city

You can save
- Only the attributes of the selected features in a separate table as follows:


Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





6
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)


- Save the geometry with the attributes
- By exporting as shapefile
- By simply creating a new layer file containing the selected features


Then



Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





7
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)




All those are accessible through the Context Menu.

Another selection:

Select schools which are located in the Eastern Province and which are using the electricity
provided by EWSA
- make the selection as follows:
- make sure the you create a new selection
- The following figure shows the query to be formulated:



Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





8
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)


The result shows 45 schools



Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





9
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)


4. Spatial join

You can use topological relationships also in different way. This operation makes a spatial
join based on location, with attributes of the feature in one layer to feature in another layer.
This is called spatial join. The added information consists of all attributes values for the
joined feature class. This information will be displayed when checking on a feature with the
information Tool.

For this exercise, you have to join the District layers with the number of the livestock using
livestock table. ( Both layers are provided during the training session)

To do so, explore first the attributes tables of both tables and find the differences. And then,
perform the attribute join to have information about description of transformers with location
of transformers

Right Click on the layer District, to open the context menu Join data from the table
Livestock as provided in the class.

For the question: Choose the layer to join this layer, select The excel Table: livestock



Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





10
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)




Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





11
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)
Click OK


Open the Attribute table of the District and explore it table. Checking the attribute table of the
output, you will find that it contains all the information about the livestock of Rwanda.


Note: You will need to create new fields and fill in the attributes from the Livestock since
there are not permanently stored.

Removing a joined table

1. Right-click the layer containing a join you want to remove and point to J oins and
Relates.
2. Point to Remove J oin(s) and click the join you want to remove.



5. Summarizing the attribute table

- Now, you may need to know the total areas of different Wetland according to their
uses ( occupation)
- Upload the wetland in the map
- Open the attribute table
- summarize the attribute table of the wetland using the using the field occupation
and areas 2 as follows:

To do this, you have to


Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





12
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)
Right click on Wetland and open the attribute table
Click on the Field Occupation

Click on Summarise.

Choose the Areas, and Tick sum
Define the location where the table will be saved: GISData and name it
summarize_Wetland



Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





13
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)


Click Ok
Accept the table to be added into arcMap ( table of Content)
From the table of Content, open the table and observe the result as follows:






Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





14
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)


6. Calculate statistics

Now you can use the statistics calculation option to know the total length of powerlines-1988
as follow:

Open attribute table of Wetland

Click on Filed Areas2 and go to Statistics.
Observe the table: You can read the maximum, minimum, etc






7. Operations on attribute tables

From the previous exercises, perform the following operations on the attribute tables of
Schools :
1. Creating a new field and filling in the description of the school like Secondary
school


Hint: Adding a field to a table

1. Click Options in the table you want to add a field to.


Geographic Information System and Remote Sensing Research and Training Centre (CGIS)
University Avenue P.O. Box 212 Huye - Rwanda;





15
UNI VERSI TY OF RWANDA
HuyeCampus
CollegeofScienceandTechnology(CST)
2. Click Add Field.
3. Type a name for the field.
4. Click the Type dropdown arrow and click the field type.
5. Set any other field properties, such as a field alias, as necessary.
6. Click OK.

Typeofrecordsmaybethefollowing:Text,numbers,Dates,...Numbers
You can store numbers in one of four numeric data types:
Short integers : -32,768 to 32,767 (2 bytes, integer values)
Long integers : -2,147,483,648 to 2,147,483,647 (4 bytes, integer values)
Single-precision floating point numbers, often referred to as floats: approximately -3.4E38 to 1.2E38 (4
bytes, fractional values)
Double-precision floating point numbers, commonly called doubles: approximately -2.2E308 to 1.8E308,
fractional values)


2. Creating a new field and filling in the description of the school like Secondary
school
3. Deleting the created field
4. Selecting the schools that are located in the Western Province, exporting the attribute
table and organizing that table into Excel
5.

You might also like