0% found this document useful (0 votes)
16 views44 pages

Lecture 10 GIS SSM - PPTX MN

Uploaded by

Mohamed elkholy
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)
16 views44 pages

Lecture 10 GIS SSM - PPTX MN

Uploaded by

Mohamed elkholy
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/ 44

GIS lecture 10:

1
1. Approaches for GIS queries

2. Thematic query:

3. Geometric query:

4. Topological query:
Query operators

The thematic query relies on the analysis of technical data (attribute data).
The query is performed using adequate selecting operators.

Three categories of operators are presented:

Relational operators: Equal and not equal greater than, smaller …………

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.
Relational operators
Shape ID Tree Type Density / m2 Soil type

polygon 1 Fitch 250 sandy


polygon 2 Tanne 250 silt
polygon 3 Khals 0 sandy
polygon 4 Larch 120 clay
polygon 5 Bunch 300 wet
polygon 6 Fitch 130 dry
polygon 7 Larche 100 clay
SQL operator
SELECT * FROM trees WHERE Treetype = 'Fichte';
Result Table Result Graph
Shape ID Tree Type Density / Soil type
m2
polygon 1 Fitch 250 sandy
polygon 6 Fitch 130 dry
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 (%).
Shape ID Tree Type Density / m2 Soil type

polygon 1 Fitch 250 sandy


polygon 2 Tanne 250 silt
polygon 3 Kahls 0 sandy
polygon 4 Larche 120 clay
polygon 5 Bunch 300 wet
polygon 6 Fitch 130 dry
polygon 7 Larche 100 clay

SQL operator
SELECT Tree Type, Denisty, soil type, denisty *2/100 as
wood usage FROM Parzelle WHERE Density > 120;
Result Graph
Result Table
Shape ID Tree Type Density / Soil type Wood
m2 usage
polygon 1 Fitch 250 sandy 5
polygon 2 Tanne 250 silt 5
polygon 5 Bunch 300 wet 6
polygon 6 Fitch 130 dry 2.6
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.

Symmetric difference; True, if exactly one is true,


XOR
excluding OR but not both.

Set difference
NOT True, if one is false.
(complement)
Shape ID Tree Type Density / m2 Soil type
polygon 1 Fitch 250 sandy
polygon 2 Tanne 250 silt
polygon 3 Kahls 0 sandy
polygon 4 Larche 120 clay
polygon 5 Bunch 300 wet
polygon 6 Fitch 130 dry
polygon 7 Larche 100 clay

Operator Query SQL


Select Tree Type, Density, soil type
Find all areas that are forested with larch and where the Density from trees
AND is greater than 110 where tree type = "Larche"and
Density > 110

Result Table Result Graph


Shape ID Tree Type Density / m2 Soil type
polygon 4 Larche 120 clay
Proximity relations are distance-based

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".
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)?


Raster Model
Vector model
Returns the position of each point from the map as x‐ and y‐coordinates.
Vector model
Returns the position of each point from the map as x‐ and y‐coordinates.
•Locating features based on their distance from other features

•Buffering features

•Spatial Join
A buffer is a spatial expansion around points, lines, and Polygons defined by a distance

point

Line

Polygon
PostGIS is an open source software program that adds support for geographic objects to
the PostgreSQL object-relational database.

PostGIS follows the Simple Features for SQL specification and stores a table’s spatial
information in geometry columns.

Spatial queries in PostGIS starts with (ST_) short for spatial

ID Shape Feature Feature Geometry


name Data column
100534 polygon …… ….. Spatial
information
100295 polygon ….. …… Spatial
information
ST_Buffer creates a buffer around a given geometry with a specified distance.

It is commonly used to create an area around a point, line, or polygon.

The buffer is represented as a new geometry object, which can be used for further
spatial analysis.

The syntax for using ST_Buffer is as follows:

ST_Buffer(geometry, radius, [options])


Write a query that creates a buffer around a point representing a city center with a
radius of 500 meters.

City center is represented as polygon in a table as “citycenter”.

ST_Buffer (citycenter.geometry , 500);


ST_Distance calculates the distance between two geometries.

It can be used to find the distance between two points, two lines, or the distance
between two polygons.

The syntax for using ST_Distance is as follows:

ST_Distance (geometry1, geometry2)


Calculate the distance between two stations “station1” and “station 2”

ST_Distance (station1.geometry, station2.geometry)


Write a query that returns the name of all cities that are less than 100 KM
from ocean (data base contains a table for cities and table for ocean)

SELECT city.name

FROM city, ocean

WHERE (ST_Distance (city.geometry, ocean.geometry) )< 100KM


(ST_Intersects) returns Boolean value

true if two geometries intersect each other and false if not.

It takes two geometry inputs and returns a Boolean (true/false) value.

The syntax for using ST_Intersects is as follows:

ST_Intersects (geometry1, geometry2)


Consider a city containing different buildings and parks write a that query returns all
the buildings from a dataset that intersect with a park which name is “Central park”:

The database includes two tables ( buildings, Parks)

SELECT * FROM buildings


WHERE ST_Intersects (buildings.geometry, (SELECT geometry FROM parks WHERE
name='Central Park'));
In this query, the ST_Intersects function is used to check if the geometry of each building in the dataset intersects with
the geometry of Central Park.

The WHERE clause filters the results to only include buildings that intersect with the park.
ST_Union in PostGIS

ST_Union merges several geometries into a single geometry.

It can be used to merge several polygons into a single polygon or to merge several lines into
a single line.

The resulting geometry is represented as a new geometry object, which can be used for
further spatial analysis or visualization.

The syntax for using ST_Union is as follows:

ST_Union (geometry1, geometry2, ...)


Write a query merges all cities that are neighbor to a certain city with cityname
“Cairo” consider table neighborhoods represent the all neighbor cities

SELECT ST_Union(geometry) FROM neighborhoods WHERE cityname = “Cairo”


Thematic queries identify elements with regards to their properties.

Geometric queries make selection of objects based on their location


(distance from other objects)

Topological quires selection criteria are based on the topological


arrangement of objects in space. (relationship between objects)
The basic idea is based on the concept that each element is
composed of
• a boundary (b),
• an interior (i),
• an exterior (e).

The concept of boundary, interior, and exterior are defined in the


general topology.
Boundary
The boundary consists of lines that separate the interior from the
exterior.
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.

Exterior
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.

Two objects, A and B, 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.
•Interior, boundary, exterior
•Let A be an object in a “Universe” U.

Red is boundary of A (A)

Green is A interior ( Ao )
U
A Blue –(Green + Red) is
( A )
A exterior
Compare only boundary and interior without exterior
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.
Overlap
Object A and object B overlap. Test for intersect (inversion of disjoint).
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.
Object A lies inside object B.
It is the opposite of "contain". If A is inside B, then B contains A
Object A covers object B. The interior of an object is completely inside the other
object and the boundaries intersect.
It is the opposite of "covers". If A is covered by B, then B covers A

You might also like