0% found this document useful (0 votes)
7 views

SpatialQueries

Uploaded by

msaqibamu98
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)
7 views

SpatialQueries

Uploaded by

msaqibamu98
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/ 48

Geographic Information Technology Training Alliance (GITTA) presents:

Spatial Queries

Responsible persons: Claudia Dolci, Dante Salvini, Robert Weibel,


Samuel Wiesmann
Spatial Queries

Table Of Content
1. Spatial Queries ......................................................................................................................................... 2
1.1. Introduction to spatial queries .......................................................................................................... 3
1.1.1. The information system ............................................................................................................. 3
1.1.2. The basic components of geographical information .................................................................. 4
1.1.3. Query classification ................................................................................................................... 6
1.1.4. Input / Output of a query .......................................................................................................... 9
1.1.5. Questions .................................................................................................................................. 12
1.2. Thematic query ............................................................................................................................... 13
1.2.1. Relational operators ................................................................................................................. 15
1.2.2. Arithmetic operators ................................................................................................................ 16
1.2.3. Logical operators ..................................................................................................................... 17
1.2.4. Combination of operators ........................................................................................................ 20
1.2.5. Formulate queries .................................................................................................................... 22
1.3. Geometric query ............................................................................................................................. 24
1.3.1. The geometric primitives ......................................................................................................... 24
1.3.2. Geometric measurement functions .......................................................................................... 26
1.4. Topological query ........................................................................................................................... 35
1.4.1. Topological relations ............................................................................................................... 35
1.4.2. Topological operators .............................................................................................................. 40
1.5. Summary ......................................................................................................................................... 44
1.6. Glossary .......................................................................................................................................... 45
1.7. Bibliography ................................................................................................................................... 46

http://www.gitta.info - Version from: 4.5.2016 1


Spatial Queries

1. Spatial Queries
PLEASE NOTE: this lesson has been translated from German to English. However, some of the figures are
still in German.
The aim of spatial queries and their analysis is to detect spatial relationships between elements of one or more
subjects, in order to locate spatial objects. The results of such analysis can be used in decision making. This
lesson is divided into four units. An introduction to the subject and the most important terms are provided in
the first unit. These terms will be discussed in more detail in the other units.
Learning Objectives
• You know the objects of queries and are able to establish a connection between database structure and
query possibilities.
• You are able to formulate a thematic query and to execute a simple and a complex query.
• You understand the basics of a geometric query and know how to perform the most important queries.
• You know the topological relationships between the objects and are able to formulate a topological query.

http://www.gitta.info - Version from: 4.5.2016 2


Spatial Queries

1.1. Introduction to spatial queries


The database structure, which is included in a GIS, enables the logical, consistent 1 and ordered storage and
management of data. Both thematic and geometric information are stored in the form of tables. In the discipline
of geoinformation, the term data analysis includes all those investigations, queries, evaluations, etc., which are
carried out on structured and stored spatial data. When a query is performed to obtain and answer to a spatial
question, the data are accessed through the basic elements of this structure which is made up of tables, fields,
data sets, values and connections.

Citation:
"The deduction of new information from existing spatial data is one of the main tasks of a geoinformation
system.
Spatial analysis comprises analysis and synthesis of spatial data to a unity [...] Every spatial analysis implies
the professional interpretation of the resuslts." (Bill 1999)

Example of a query:
"Which proportion of the inhabitants of Zürich lives more than 200m away from a public transport stop?"

1.1.1. The information system


An information system is a question#answer system based on a data set. This system contains tools for the
computer based analysis and handling of information. Such a system is called geographic information system
(GIS) if the data are geographically referenced (Carosio 2000). A GIS is composed of various individual
components. Some of these functions are basic, while others are more complicated or required for special
applications. The user interface, query functions and the data management system play an important role.
The user interface enables the user to communicate with the system. It allows users to start operations, query
information, etc. Via the user interface, analysis functions can be executed through accessing the data. Data
access and data management in general is controlled by the database management system.
Have a look at the following illustration to get an idea of information systems:

Fig. A: Architecture of a database

1
Gewährleisten der Widerspruchsfreiheit innerhalb einer Datenbank; d. h., dass der Inhalt einer Datenbank alle vordefinierten
Konsistenzbedingungen ("Constraints") erfüllt.

http://www.gitta.info - Version from: 4.5.2016 3


Spatial Queries

Fig. B: Structure of a table

1.1.2. The basic components of geographical information


A commercial GIS stores spatial data and its attributes in separate data files in which corresponding lines are
linked by a unique identification number. This identification number allows a GIS to search for attribute values
and to display them based on spatial query criteria, and vice versa.
In the geometric representation of an object, information about its attributes can be derived by selecting this
object in a GIS. There is also the possibility to identify an object by its geometric representation by selecting
its entry in the attribute table.
The data structure comprises the connection of thematic and geometric information. The geometry is expressed
in the spatial reference. A spatial reference is assigned to all the objects in a greater or lesser extent.
Spatial references describe the location and extent of this geographic information. In addition to the metric
properties (geometry), topological properties should also be mentioned. Topological properties are expressed
by information about e.g. relations of neighborhood (what object is neighboring?), containedness (does an
object contain other objects?), overlap (is an object overlapped by other objects?), etc. In addition to geometric
and topological properties, thematic properties are also assigned to each object. They are stored in tables. The
geometric and thematic information affect each other. These so#called objects are subject to temporal changes.
(Bartelme 2000).

http://www.gitta.info - Version from: 4.5.2016 4


Spatial Queries

Fig. C: Basic components of a GIS

Example 1:

Example 2:

http://www.gitta.info - Version from: 4.5.2016 5


Spatial Queries

1.1.3. Query classification


The aim of spatial selection and analysis is to determine spatial relationships between one or more subjects in
order to locate those elements in space. The results can then be used for decision#making. Performing a query,
a number of criteria have to be formulated. To do so, the following approaches are possible:
• Thematic query:
Selection of all objects which achieve the required conditions (attributes). E.g.: "Select all spruce trees."
• Geometric query:
Selection of all objects which achieve the required spatial conditions. E.g.: "Select all the houses that
are located less than 250 m away from the river".
• Topological query:
Selection of all objects which achieve the required conditions regarding the spatial relations between the
objects. For example: "Select all the buildings that are lying in zone 1".

http://www.gitta.info - Version from: 4.5.2016 6


Spatial Queries

Subquery
Queries can be performed on the entire data set or a subset of the data. Subsets are generated via
queries. A subquery is a SELECT statement that is incorporated in a SELECT, SELECT...INTO ,
INSERT...INTO , DELETE , UPDATE statement or in another subquery. A subquery is composed of
three parts.
Part Description
Comparison predicate and a comparison operator that compares the
predicate with the result of the subquery.
Expression An expression that is searched for in the result of the
subquery.
SQL statement A SELECT statement according to the usual format of
the SELECT statement. It must be in parentheses.

Example:
SELECT * FROM product WHERE product-ID IN (SELECT product-ID FROM
orders WHERE discount >= .25);

A query can be classified in two ways, based on the result:


• Direct query:
Data are accessed interactively by the user or by an application program. Thus, a subset can be extracted,
while the original data remains unchanged. The selection commands can be entered in command lines
or query masks. More complex queries that require multiple single line commands can be prepared
as sequences of command lines (batch, macro). In order to formulate queries, there is a formal query
language. Many GIS support SQL 2 (Structured Query Language) as query language for thematic topics
(see unit "Thematic Selection").
• Manipulation:
By manipulating, new geographic information elements can be created. These new elements can be used
for analysis purpose in further steps. In general, the new objects have to be previously conceptually
modeled , and their data structure has to be implemented in the GIS. Some GIS can generate a minimal
data structure (without thematic attributes) automatically. New information can be generated combining
different objects. They can be used for further analysis.

2
"Acronym for Structured Query Language. A syntax for retrieving and manipulating data from a relational database. SQL has
become an industry standard query language in most relational database management systems" , e.g. Oracle, DB2, Access, etc.

http://www.gitta.info - Version from: 4.5.2016 7


Spatial Queries

Fig. D: Classification of the query into direct query and manipulation

http://www.gitta.info - Version from: 4.5.2016 8


Spatial Queries

Fig. E: Splitting the direct query

1.1.4. Input / Output of a query


A query relates to specific datasets and the data type defines whether a certain query is possible or not. The
common data types in a GIS are vector and raster and also tables. Thus, the queries on raster data are different
than the queries on vector data, although the question to be answered is the same. The number of data sets
included into the query also plays a role. The query can refer to a single or multiple data sets. The relationships

http://www.gitta.info - Version from: 4.5.2016 9


Spatial Queries

between the data involved in the query are given via the topology 3 (geometry) or the tables (theme). Tables
can also be related to each other. The content of the tables can be linked via key attributes. Thus, a query can
be performed over several linked tables.

Fig. F: Linked tables

The result of a query can be presented in different forms. The result should be presented in a form which is
easy for the user to read. Normally, the results are presented as maps, tables, or figures, or in another format
which allows data sharing. The following are examples of data presentation:
1. Digital data transfer
2. Interactive graphics on screen
3. Tables, reports, and similar representations
4. Passive graphics in form of maps

3
Die Topologie beschäftigt sich mit den räumlichen und strukturellen Eigenschaften der geometrischen Objekte unabhängig von ihrer
Ausdehnung und ihrer Form. Die topologischen Eigenschaften äussern sich in Beziehung der Nachbarschaft, des Enthaltenseins, der
Überschneidung und Ähnlichem.

http://www.gitta.info - Version from: 4.5.2016 10


Spatial Queries

Some examples
Layer 1 Layer 2 Inputs Query Type Res. table Res. graphic
Find the THEM
buildings,
which have
an area of
more than
100m2.

Find the GEOM +


buildings, THEM
which have
an area of
more than
100m2 and
which are
within a
distance of
100m to
Adelriver.
Find the TOPO
buildings,
which are
completely
within the
forest.

Find the GEOM


area, which
is within a
distance of
100 m to
Adelriver.

http://www.gitta.info - Version from: 4.5.2016 11


Spatial Queries

Find the GEOM


building,
which is
closest to
Adelriver.

Exercise
What does the spatial information in a GIS mainly consist of?

1.1.5. Questions
Question 1
How can space related information be divided?
Question 2
Which approaches can be used to formulate a query?
Question 3
Describe the inputs which should be used to answer the following questions and what would the outputs
look like:
"Find all buildings which are located on parcels with a minimal area of 1000 m2 and a distance of more than
250m to the highway".

http://www.gitta.info - Version from: 4.5.2016 12


Spatial Queries

1.2. Thematic query


Thematic queries 4 result in the selection of thematic information. This process is comparable to a query of a
conventional database, whose data have no spatial reference.

Query language
In a GIS, queries are performed either with SQL or internal query languages. In a standard GIS the commands
are directly entered; in contrast, in a desktop GIS, the commands have to be selected using a dialogue system.
The functionalities of SQL are explained in the "Database Management and Systems Module" (lesson 4:
Structured Query Language SQL).
In the following examples, some user#friendly interfaces for SQL formulations of thematic queries are shown.
With a few clicks the desired SQL commands are compiled. Behind the interface, the SQL syntax is used to
query the database.
Example 1: ArcView Interface

Example 2: ArcGIS Interface

4
Die Abfrage ermittelt räumliche Beziehungen zwischen Elementen eines oder mehrerer Themen, um auf dieser Basis eine Lokalisierung
von Objekten zu erreichen. Die Analyseergebnisse können dann bei konkreten Fragestellungen zur Entscheidungsfindung beitragen.

http://www.gitta.info - Version from: 4.5.2016 13


Spatial Queries

Query operators
A particular feature that distinguishes a GIS is the possibility to query specific thematic information about
selected objects. The thematic query relies on the analysis of technical data (attribute data). The query is
performed using adequate selecting operators. In the following, three categories of operators 5 are presented:
• Relational operators: Besides the equal sign, relational operators can be used to formulate queries as well.
• Arithmetic operators: These operators are used for numeric attributes. E.g. there is the possibility to
calculate the mean of an attribute or the sum of attribute values from a series of objects.
• Logic operators: Conditions are formulated with logic operators. The semantics (meaning) of these
operators are similar to the meaning "AND", "OR" etc.

5
In search algorithms, operators enable the logical conjunction of search items using keywords like AND, OR, and NOT.

http://www.gitta.info - Version from: 4.5.2016 14


Spatial Queries

1.2.1. Relational operators


The relational operators are not only used for numeric attributes, but also for text attributes and other data
types. The comparisons "greater than", "less than" etc. are related to the position of an "alphabetical" order
used in a computer.
Relational operators sometimes, other spellings are used
= EQ (equal to)
> GT (greater than)
>= GE (greater than or equal to)
< LT (less than)
<= LE (less than or equal to)
<> NE (not equal to)

SQL provides the following additional functions for analysis (aggregate functions):

• Avg function (average)


• Count function (number)
• Min, Max function (minimum, maximum)
• StDev, StDevP function (standard deviation, standard deviation of the population)
• Sum function (sum)
• Var, VarP function (variance, variance of the population)

An example - relational operators


INPUT

Graphic

Table ''Parcels: tree species (Baumart), stock (Vorrat), and soil type (Bodentyp)''

QUERY AND RESULTS


SQL operator Result: table Result:
graphic
SELECT * FROM Parzelle WHERE
Baumart = 'Fichte';

http://www.gitta.info - Version from: 4.5.2016 15


Spatial Queries

SELECT Baumart, Vorrat,


Bodentyp FROM Parzelle
WHERE Bodentyp = 'Redzina';

SELECT * FROM Parzelle WHERE


Vorrat >120;

SELECT * FROM Parzelle WHERE


Vorrat >= (SELECT AVG
(Vorrat) FROM Parzelle);

1.2.2. Arithmetic operators


Arithmetic operators are used for numerical attributes. For example, there is the possibility to calculate the
mean or the sum of attribute values from a series of objects. The following operators can be used as arithmetic
operators: Multiplication (*), division (/), addition (+) and subtraction (#) as well as the exponent operator
(exp) and modulo operator (%).
Arithmetic operators
+
-
*
/
exp
%
The first five operators are self#explanatory. The modulo operation gives the remainder from integer division.
For example:
5%2=1
6%2=0

An example – arithmetic operators


INPUT

Graphic

Table ''Parcels: tree species (Baumart), stock (Vorrat), and soil type (Bodentyp)''

http://www.gitta.info - Version from: 4.5.2016 16


Spatial Queries

QUERY AND RESULT


SQL operator Result
SELECT Baumart, Vorrat, Bodentyp,
Vorrat*2/100 as Holznutzung
FROM Parzelle
WHERE Vorrat > 120;

1.2.3. Logical operators


Arbitrarily complex conditions can be formulated. Thereby concatenations of the individual conditions have
to be extended. Complex queries are formulated by combining different attributes.
For such queries, logical operators are used to combine the expressions (with two possible values "true" or
"false").
Logical operators Meaning Result Venn diagrams
AND Intersection True, if both are true.

OR Union True, if at least one is true.

XOR Symmetric difference; True, if exactly one is


excluding OR true, but not both.

http://www.gitta.info - Version from: 4.5.2016 17


Spatial Queries

NOT Set difference True, if one is false.


(complement)

To make such queries understandable, Venn diagrams are used. Have a look at the previous table and the
following explanation.
The circles number 1 and 2 graphically represent two conditions: the shaded area represents the true statement,
while the part outside the circle does not correspond to a result.
To explain this situation, the above example is used.

Circle 1 : Tree species = "larch"


Circle 2 : Stock > 110 m3/ha

Some examples
In the following, it is shown for each operator how SQL#queries are formulated and how the results are
presented.
INPUT

Graphic

Table

Example 1:
Operator Query SQL
AND Find all parcels that are forested with larch and select ParzelleID, Baumart,
where the stock is greater than 110m3/ha. Vorrat
from Parzelle
where Baumart = "Lärche"and
Vorrat > 110

http://www.gitta.info - Version from: 4.5.2016 18


Spatial Queries

Example 2:
Operator Query SQL
OR Find all parcels that are forested with larch or select ParzelleID, Baumart,
where the stock is greater than 110m3/ha. Vorrat
from Parzelle
where Baumart = "Lärche"
or Vorrat > 110

Example 3:
Operator Query SQL
XOR Find all parcels that are forested with larch or select ParzelleID, Baumart,
where the stock is greater than 110m3/ha, but Vorrat
which do not meet both of these conditions. from Parzelle
where Baumart = "Lärche"
xor Vorrat > 110

http://www.gitta.info - Version from: 4.5.2016 19


Spatial Queries

Example 4:
Operator Query SQL
NOT Find all parcels which are forested with larch but select ParzelleID, Baumart,
where the stock is not greater than 110m3/ha. Vorrat
from Parzelle
where Baumart = "Lärche"
not Vorrat > 110

1.2.4. Combination of operators


By combining operators, it is possible to link multiple conditions.
The Boolean operators are not commutative. That means, in complicated expressions the result depends on the
mathematically defined order of the subparts of the expression. Using brackets, the order can be completely
changed (Bill 1999).

http://www.gitta.info - Version from: 4.5.2016 20


Spatial Queries

Nested Queries

Circle 1: Tree species = "Larch"


Circle 2: Stock > 110 m3/ha
Circle 3: Density > 80%
Venn-diagram Condition Corresponding SQL query
(3 AND 2) OR 1 Select *
from Parcel
where (Density > 80% and Stock > 110 m3/ha)
or Tree species = "Larch"

1 AND (3 OR 2) Select *
from Parcel
where Tree species = "Larch"
and (Density > 80% or Stock > 110 m3/ha)

(3 XOR 1) AND 2 Select *


from Parcel
where (Density > 80% xor Tree species =
"Larch" )
and Stock > 110 3/ha

(2 OR 1) NOT 3 Select *
from Parcel
where (Stock > 110 m3/ha or Tree species =
"Larch")
not Density > 80%

http://www.gitta.info - Version from: 4.5.2016 21


Spatial Queries

3 OR (2 XOR 1) Select *
from Parcel
where Density > 80% or (Stock > 110 m3/ha
xor Tree species = "Larch")

Applications
Try to solve the following exercises. Consider, in particular, which operator is used:
Select all the roads of the type "Nebenstrasse", where the speed is limited to 50km/h (select the objects by
clicking on the rows of the table).

Only pictures can be viewed in this version! For Flash, animations, movies etc. see online version.
Only screenshots of animations will be displayed. [link]

Select all the roads (all road types), where the speed is limited to 50km/h (select the objects by clicking on
the rows of the table).

Only pictures can be viewed in this version! For Flash, animations, movies etc. see online version.
Only screenshots of animations will be displayed. [link]

Select all the roads, where the speed is limited to 50km/h and which are not "Nebenstrassen" that have no
limited velocity of 50km/h. Select also all the roads which are "Nebenstrasse" and which have no speed limit
of 50km/h (select the objects by clicking on the rows of the table).

Only pictures can be viewed in this version! For Flash, animations, movies etc. see online version.
Only screenshots of animations will be displayed. [link]

Select all the roads, where the speed is limited to 50km/h, but which are not "Nebenstrassen" (select the objects
by clicking on the rows of the table).

Only pictures can be viewed in this version! For Flash, animations, movies etc. see online version.
Only screenshots of animations will be displayed. [link]

1.2.5. Formulate queries


Formulate possible queries for the example below and try to differentiate the different query types. Publish
your article in the discussion forum on WebCT.

http://www.gitta.info - Version from: 4.5.2016 22


Spatial Queries

Parzelle TABLE

Besitzer TABLE

Preis TABLE

http://www.gitta.info - Version from: 4.5.2016 23


Spatial Queries

1.3. Geometric query


In addition to the information and search options based on theme, analysis functions based on spatial
(geometric and topological) selection criteria are also implemented in GIS. In this unit, the geometric query
is discussed. The geometry can be measured, such as the area or the perimeter of an object, or the distance or
direction between two objects, respectively (measuring functions). To explain these concepts, it is important
to distinguish between raster and vector models.

1.3.1. The geometric primitives


In VECTOR MODELS, information is assigned to points. All the other structures (lines and polygons) are
based on points. The geometry of all other structures can be derived based on the coordinates of the points,
such as the length of the connection line between two points, the area of a surface, and the distance between
two objects (Bartelme 2000).
The three geometric primitives are arranged in 2D space, as shown in the following table.

Point
A 2D point is defined by the x# and y#coordinates.

Line
Line segments consist of one or more point pairs. Two points of a segment can be connected by a straight line
or an arc. This means that lines can be made up of straight lines, curves, or a mixture of the two.

Polygon
Polygons (areas) are composed of connected lines that form a closed geometric shape. The enclosed area is
the polygon.
Complex geometries can be modeled as ordered sequences of the geometric primitives.
DESCRIPTION GRAPHIC TABLE
Point
Position, no area.
Defined by the coordinates.

http://www.gitta.info - Version from: 4.5.2016 24


Spatial Queries

Line
Length, no width.
Defined by several segments,
which always connect two points.

Area
Area and perimeter.
Defined by several segments,
which form a closed polygon.

In RASTER MODELS, all values are stored in a simple array (matrix). In addition, there is a file header,
which contains the following information:
• Number of rows and columns
• Cell size
• Minimum value of x# and y#coordinates
For example:
Ncols 270
Nrows 476
Xcorner 708152.60
Ycorner 121673.90
Cellsize 1
NODATA_Value -9999
DESCRIPTION GRAPHIC TABLE
Point
One cell

http://www.gitta.info - Version from: 4.5.2016 25


Spatial Queries

Line
Several neighboring cells in which
normally one cell is connected at
the edges and corners with just one
or two neighboring cells.

Area
Group of neighboring cells
connected at the edges and corners.

1.3.2. Geometric measurement functions


Geometry is a property of an object, just as is the thematic. With the appropriate measuring functions, queries
can be performed. The general geometric queries are listed below:

Position – where (x, y)?

Vector model
Returns the position of each point from the map as x# and y#coordinates.

http://www.gitta.info - Version from: 4.5.2016 26


Spatial Queries

Raster model
Example: Block encoding
Value No. Cell Location
1 8 4,2 5,2 6,2
4,3 5,3
4,4 5,4
5,5
2 7 7,2
6,3 7,3
6,4 7,4
6,5 7,5

Distance

Vector model
For vector data, the distance between two objects is calculated according to the Pythagorean Theorem and
corresponds to the shortest distance.

http://www.gitta.info - Version from: 4.5.2016 27


Spatial Queries

Distance between point A and B

Example: The distance is 11,3 cm.

Euclidean distance

Raster model
In the raster model, there are three different approaches to measure the distance between points.
Straight line between point A and point B

Beispiel:
Mit einer Auflösung von 2 cm beträgt die Distanz 11,3 cm.

Euclidean distance

Distance along the cell boundary between points A and B.


Example:
Using a resolution of 2 cm, the distance is16 cm.

Manhattan distance

http://www.gitta.info - Version from: 4.5.2016 28


Spatial Queries

Concentric zones with same distance around point A.


Example:
Using a resolution of 2 cm, the distance is 11,3 cm.

Neighborhood

Practical examples
WHERE
In ArcInfo "Measuring Where" returns the x, y position of a selected point on a map.

LENGTH
In ArcInfo "Length" returns the length of a line section, which consists of two or more points.

http://www.gitta.info - Version from: 4.5.2016 29


Spatial Queries

WITHIN A CERTAIN DISTANCE


Two objects are lying "within a certain distance" if the distance between them is smaller than the given distance.
Traditional GIS software offer pre#programmed tools to answer these questions.
Question 1:
Select all mountain peaks that are less than 500m away from the cabins (planimetric).

Question 2:
Select all the trees that are less than 200m away from the collection point.

http://www.gitta.info - Version from: 4.5.2016 30


Spatial Queries

Size

Vector data model

PERIMETER
Sum of the length of all single sections.
AREA
Sum of the area of the simple geometric
shapes (e.g. triangles and rectangles), into
which the main object can be devided.

Raster data model

http://www.gitta.info - Version from: 4.5.2016 31


Spatial Queries

PERIMETER
Number of cell edges, which delimit the object, multiplied by the resolution of the
cells.
Example:
Using a cell resolution of 2cm, the perimeter is 32 cm.
AREA
Number of cells, which define the object, mutliplied by the area of one cell..
Example:
Using a cell resolution of 2cm, the area is 60 cm2.

Proximity analysis / buffering

Vector data model


A buffer is a spatial expansion around points, lines and polygons defined by a distance.
Point buffer

Line buffer

Polygon buffer

Raster data model


In the raster data model, proximity is calculated for the entire raster. Then a certain distance is chosen. For in-
depth look have a look at the lesson Accessibility.

http://www.gitta.info - Version from: 4.5.2016 32


Spatial Queries

Applications

Vector data model


Question 1:
Canopy of trees
Vector data model

Raster data model

Question 2:
Calculation of the flooded area
Vector data model

http://www.gitta.info - Version from: 4.5.2016 33


Spatial Queries

Raster data model

Question 3:
Flooding zone of a lake
Vector data model

Raster data model

http://www.gitta.info - Version from: 4.5.2016 34


Spatial Queries

1.4. Topological query


Standing at a crossroad, holding a situation map in the hands, it is realtively easy to determine which roads are
crossing and which buildings are situated next to each other (ESRI). The implementation and further use of
such functions in a GIS, however, require some knowledge.
While spatial selection criteria select objects based on their location, and while thematic queries identify
elements with regards to their properties, the topological selection criteria are based on the topological
arrangement of objects in space. Topological arrangements of objects are accessed through features such as
"next", "part of" or "within".
In a GIS, spatial relationships are named "topology". Topological relations are made up of the geometric
primitives: Point (simplest element), line (connected points), polygons (connected lines) (ESRI). Based on
these structures, the system is able to identify topological relationships and perform analyses.

1.4.1. Topological relations


Topology deals with spatial and structural properties of geometric objects, independent of their extension, type,
or geometric form. Among the types of topological properties of objects there are: the number of dimensions
an object has or the relationships that exist between objects. All topological properties are invariant to any
continuous deformation of space (Saaty 1980). The topology simplifies analysis functions, as the following
examples show: joining adjacent areas with similar properties. It is important to distinguish between vector
data formats and raster data formats. For example, imagine an area represented by a vector data model: it is
composed of a border, which separates the interior from the exterior of the surface. The same area represented
by a raster data model consists of several grid cells. There is no border existing as a separating line. Thus, the
algorithms implemented for vector data models are not valid for raster data models. In the following example,
we only show topological operations in vector data models.
VECTOR An interesting method for the classification of topological relations was proposed by Egenhofer
(1993) (Worboys et al. 2004). It is called the 9#intersection schema. This intersection scheme is an elegant
approach for the classification of topological configurations. The basic idea is based on the concept that each
element is composed of a boundary (b), an interior (i), and an exterior (e). The concept of interior, boundary
and complement (exterior) are defined in the general topology.

Boundary
The boundary consists of points or lines that separate the interior from the exterior. The edge of a line consists
of the endpoints. The boundary of a polygon is the line that defines the perimeter.

Interior
The interior of an object consists of points, lines or areas that are in the object but do not belong boundary.

Complement
The complement, also called exterior, consists of the points, lines and areas which are not in the object.
The basic method used to compare two geometrical objects is to analyze the intersections between all the
possible pairs that can be built with the interior, exterior and boundary of these two objects. Based on the
resulting "intersection" matrix, the relationships between the two geometrical objects can be classified.
Two objects, A and B, are given. Both of them are represented by their interior (i), boundary (b) and exterior
(e). There are nine possible relations of these two geometrical objects. They are shown in the following table.

http://www.gitta.info - Version from: 4.5.2016 35


Spatial Queries

The 4#intersection#matrix is sometimes used as basis for the analysis of topological relations. It is generated
by omitting the components of the exterior. It is less powerful than the 9#intersectionmatrix.

The most important topological relations between objects that are used in GIS applications are listed in
the following sequence. Note that there are three different geometries (point, line, polygon) on which the
topological relations are applied.

Disjoint
There is no intersection area between object A and object B. Test for disjoint.

Meet
Object A and object B meet at the boundary. The boundaries meet, but not the interior. Two geometry objects
meet if the boundaries touch. Test for touch.

Overlap
Object A and object B overlap. Test for intersect (inversion of disjoint).
Overlap with disjoint: The interior of an object intersects the boundary and the interior of the other object,
but the boundaries do not intersect. That is the case if a line starts outside a polygon (area) and ends in the
interior of the polygon.
Overlap with Intersect: The boundaries and the interior of both objects intersect. If a geometry object has to
intersect another geometry object the geometry needs to be part of the dimension of the bigger object. That
means:
• Points
- Cannot intersect with points, lines or areas.
• Lines
- Cannot intersect with points.
- Can intersect with other lines » intersection = point.
- Can intersect with polygons » intersection = lines (or points).

Contains
Object A contains object B. Test whether the initial geometry object encloses a different geometry object. The
interior and the boundary of an object are completely inside of the other object. A geometry object cannot
contain a geometry object of higher order. E.g.:
• Points can not contain lines or polygons.
• Lines can not contain polygons.

http://www.gitta.info - Version from: 4.5.2016 36


Spatial Queries

Inside
Object B lies inside object A. It is the opposite of "contain". If A is inside B, then B contains A.

Covers
Object A covers object B. The interior of an object is completely inside the other object and the boundaries
intersect. A geometry object can’t include a geometry object of higher dimension. That means:
• Points can not contain lines or polygons.
• Lines can not contain polygons.

Covered by
Object B is covered by object A. It is the opposite of "covers". If A is covered by B, then B covers A.

Equal
Object B and object A match. Test for equality of the initial geometry object and a different geometry object.
The interior and the boundary of an object are lying on the boundary of the other object and vice versa. This
happens when a line falls exactly on the boundary of a polygon. The coordinates of all components have to be
equal. The compared geometry objects must be equal. That means:
• Point = point
• Line = line
• Polygon = polygon
The following table shows the most common topological relations:
poly-poly line-line point-point poly-line poly-point line-point
Disjoint

Meet

Overlap

Contains

Inside

http://www.gitta.info - Version from: 4.5.2016 37


Spatial Queries

Covers

Covered by

Equal

The following table shows the 9#intersetion#schema and the 4#intersection#schema for some typical
topological relations between two polygons, proposed by Egenhofer et al. (1993). The relations are given by
the values 0 and 1. Every pair has an empty (0) or an occupied (1) intersection.
Topological relation Graphical description 4-intersection-matrix 9-intersection-matrix
Disjoint

Meet

http://www.gitta.info - Version from: 4.5.2016 38


Spatial Queries

Overlap

Contains

Inside

Covers

http://www.gitta.info - Version from: 4.5.2016 39


Spatial Queries

Covered by

Equal

There is at least one disadvantage in this model: there is no possibility to conceptually separate different
situations.

These three situations presented correspond to the following matrix:

1.4.2. Topological operators


Topological operators are components of spatial analysis functions of a GIS. These functions are fundamental
and therefore implemented in commercial GIS, such as ArcGIS, Geomedia or MapInfo. Each system has its
own formulations of spatial queries; some of them allow the user to perform topological queries using SQL.
Spatial databases, such as Oracle, have been and continue to be, developed for data management purposes in

http://www.gitta.info - Version from: 4.5.2016 40


Spatial Queries

GIS. Further topological operators, which are adapted to the corresponding data structure, are developed. In the
following list some of the functions and the corresponding operators, provided by Geomedia, Oracle Spatial
and ArcView, are shown.
TOPOLOGICAL ORACLE GEOMEDIA ARCVIEW
RELATION
Disjoint disjoint - are within a distance of
Meet touch meet -
Overlap overlap by intersect overlap intersect
Contains contains entirely contains completely contains
Inside covers are entirely contained by contains the center of
Covers inside contain have their center in
Coverered by coveredby are contained by are completely within
Equal equal are spatially equal -

Relationships between polygons and other objects are the most frequent. Below are some examples of
topological queries:
LAYERS INPUT QUERY RESULTS
N.1 N. 2 Table Graphically
Find the
buildings,
which lie
completely
within the
forest.

Find the
buildings,
which intersect
the boundary
of the forest.

http://www.gitta.info - Version from: 4.5.2016 41


Spatial Queries

Find the
buildings,
whose centroid
lies within the
forest.

Application
As described earlier, topological queries refer to the reciprocal locations of objects in space. The following
examples illustrate this concept.
Select the huts that are reached first from the starting point (green point).

Only pictures can be viewed in this version!


For Flash, animations, movies etc. see online
version. Only screenshots of animations will
be displayed. [link]

Select the huts that are in the forest (dark green area).

Only pictures can be viewed in this version!


For Flash, animations, movies etc. see online
version. Only screenshots of animations will
be displayed. [link]

Select the areas that touch the forest (dark green area).

http://www.gitta.info - Version from: 4.5.2016 42


Spatial Queries

Only pictures can be viewed in this version!


For Flash, animations, movies etc. see online
version. Only screenshots of animations will
be displayed. [link]

Which parcels are crossed by the river Allenbach?

Only pictures can be viewed in this version!


For Flash, animations, movies etc. see online
version. Only screenshots of animations will
be displayed. [link]

http://www.gitta.info - Version from: 4.5.2016 43


Spatial Queries

1.5. Summary
An information system is a question#response system based on a data set. Such systems contain tools
for the computational analysis of information. If the stored data have a spatial reference, the system is
called geographic information system (GIS). It allows the interrogation and display of attribute values based
on spatial criteria and vice versa. Hence the term data analysis, that includes all those analysis, queries,
evaluations etc. that can be performed on structured and stored geodata. Queries can be performed according
to different approaches: thematic, geometric and topological. Geometry is expressed by the spatial reference,
which is assigned to all objects. They fulfill the requirement of location and extension. The topological
properties are expressed by the relations of neighborhood, containment, and overlapping etc. Besides geometric
characteristics that exist for spatial data, there are also thematic properties. Those properties are stored in
tables. A query can be classified in two ways, depending on the result. In a direct query, there is a subset
extracted from the database and the original data are not modified by this process. In a manipulation, new space
related information elements are generated, which can be used in further analysis operations. The results of
data processing and data manipulation in GIS should be represented in a form which is understandable for the
user, or in a form which enables data sharing.

http://www.gitta.info - Version from: 4.5.2016 44


Spatial Queries

1.6. Glossary
Abfrage:
Die Abfrage ermittelt räumliche Beziehungen zwischen Elementen eines oder mehrerer Themen, um
auf dieser Basis eine Lokalisierung von Objekten zu erreichen. Die Analyseergebnisse können dann bei
konkreten Fragestellungen zur Entscheidungsfindung beitragen.
Konsistent:
Gewährleisten der Widerspruchsfreiheit innerhalb einer Datenbank; d. h., dass der Inhalt einer Datenbank
alle vordefinierten Konsistenzbedingungen ("Constraints") erfüllt.
Operators:
In search algorithms, operators enable the logical conjunction of search items using keywords like AND,
OR, and NOT.
SQL:
"Acronym for Structured Query Language. A syntax for retrieving and manipulating data from a relational
database. SQL has become an industry standard query language in most relational database management
systems" (ESRI), e.g. Oracle, DB2, Access, etc.
Topologie:
Die Topologie beschäftigt sich mit den räumlichen und strukturellen Eigenschaften der geometrischen
Objekte unabhängig von ihrer Ausdehnung und ihrer Form. Die topologischen Eigenschaften äussern sich
in Beziehung der Nachbarschaft, des Enthaltenseins, der Überschneidung und Ähnlichem. (Carosio 2000)

http://www.gitta.info - Version from: 4.5.2016 45


Spatial Queries

1.7. Bibliography
• Bartelme, N., 2000. Geoinformatik – Modelle, Strukturen, Funktionen. 3rd. Berlin: Springer.
• Bill, R., 1999. Grundlagen der Geo-Informationssysteme. Karlsruhe: Wichmann Verlag.
• Carosio, A., 2000. Geoinformationssysteme – Band 1. Institut für Geodäsie und Photogrammetrie, ETH
Zürich.
• Egenhofer, M.J., 1993. A model for detailed binary topological relationships. Geomatica, Vol. 47, no.
3-4, 261-273.
• ESRI. ArcInfo Help.
Download: http://www.esri.com
• ESRI. GIS Dictionary: SQL [online]. Available from: http://support.esri.com/en/knowledgebase/
Gisdictionary/browse [Accessed 02.05.2016].
• Longley, P.A.; Goodchild, M.F.; Maguire, D.J.; Rhind D.W., 1999. Geographical Information
Systems. Principles, techniques, applications and management. New York, etc.: John Wiley & Sons.
• Saaty, T.L., 1980. The Analytic Hierarchy Process: Planning Setting Priorities, Resource Allocation.
New York: McGraw-Hill International.
• Worboys, M., Duckham, M., 2004. GIS. A Computing Perspective. Chapter 4. Models of geospatial
information. Boca Raton, etc.: CRC Press.

http://www.gitta.info - Version from: 4.5.2016 46

You might also like