Topic 5 – Spatial Querying and Measurement

advertisement
GEOG 60 – Introduction to Geographic Information Systems
Professor: Dr. Jean-Paul Rodrigue
Topic 5 – Spatial Querying and Measurement
A – Querying Features of a Spatial Database
B – Querying Using Spatial Attributes
C – Measuring Length and Shape
D – Measuring Distance
A
Querying Features of a Spatial Database
■
■
■
■
1. What is Querying?
2. Basic Operators
3. Boolean Search
4. Successive Search
What is Querying?
■ Narrowing down information
Records
• A GIS is composed of a
database.
• Spatial attributes linked to their
features.
• Most GIS have a huge list of
records.
GIS Database
Query
Relevant
records
1
Query results
• Impossible to find manually the
information needed.
• Need an automated procedure to
extract from the database the
records useful for a task.
• Very important task in any
DBMS.
1
What is Querying?
■ DBMS Strategy
• Using fields in a database to find records satisfying at set of
conditions.
• Conditions are defined by operators applied to fields.
• Logical operation.
• Operators either return True of False.
• Records that are true are selected (“flagged”).
• Records that are false are discarded.
Age
Age
23
Operator:
23
47
Age < 30
47
19
19
35
35
What is Querying?
Search space
■ Search space
• Set of all records in a database.
• Information over which a query is
performed.
■ Search result
Search
results
“False” records
“True” records
“False” records
Search
results
1
“True” records
• Set of all records that satisfy a
query.
• All records that are True.
• A search result can become a
search space.
2
Basic Operators
■ Equivalence
• A record must be equal to a condition.
• Record name always put in brackets [].
• = symbol used.
• ([State_name] = “California”).
• Wildcards can be used for equivalence.
•
•
•
•
•
Applies only to strings.
* is the multiple character wildcard.
? is the single character wildcard.
([Owner_name] = “M*”).
([Owner_name] = “?erry”).
2
Basic Operators
■ Difference
•
•
•
•
•
•
•
A record must be different from a condition.
This difference is either a numeric or alphanumeric.
A bounding value (BV) is required.
> greater than BV; < lesser than BV.
>= greater of equal to BV; <= lesser or equal to BV.
([City_name] >= "m" ).
([Pop97] < 10000).
2
Basic Operators
■ Mathematical
• Used in conjunction with equivalence and difference.
• Perform an operation the record value must satisfy to.
• Standard addition (+), subtraction (-), multiplication (*) and
division (/).
• Priority in operation.
• * and / have the highest.
• + and - have the lowest.
• Putting operations in parentheses prioritize them.
• ([Pop97] / [Area] >= 25).
• ([Netvalue]> [Area] * ([Price] + [Tax]))
3
Boolean Operators
■ Combination of conditions
• Either True or false.
• Exclusion:
• And is an intersection of two sets.
• ([area] > 1500) and ( [b_room] > 3).
• Inclusion:
• Or is an union of two sets.
• ([age] < 18 or [age] > 65).
• Subtraction:
• Not is a subtraction from one set of another set.
• ([sub_region] = "N Eng") and ( not ( [state_name] = "Maine")).
3
Boolean Operators
California
Set A
Set B
Pacific Coast
AND
Set A
True
Set B
True
Selection
Yes
True
False
False
False
True
False
No
No
No
3
Boolean Operators
California
Set A
OR
Set B
Nevada
Set A
True
True
Set B
True
False
Selection
Yes
Yes
False
False
True
False
Yes
No
3
Boolean Operators
NOT
California
Set A
Set B
Los Angeles
Set A
True
True
Set B
True
False
Selection
No
Yes
False
False
True
False
No
No
4
Successive Query
■ New Set
• Makes a new selected set containing the features or records
selected in a query.
• Features or records not in this set are deselected.
■ Add To Set
• Adds the features or records selected in a query to the existing
selected set.
• Widens a selection.
■ Select From Set
• Selects the features or records in a query from the existing
selected set.
• Only those features or records in this existing set that are
selected in a query will remain in the selected set.
• Narrows down a selection.
Selected
Records
Add to Set
Selected
Records
Select from Set
Selected
Records
Selected
Records
Records
New Set
Selected
Records
4
Successive Query
Query
B
Querying Using Spatial Attributes
■ 1. Querying Based on Proximity
■ 2. Querying Based on Membership
■ 3. Querying Based on Intersection
1
Querying Based on Proximity
Search distance
Search radius
Adjacency
2
Querying Based on Membership
3
Querying Based on Intersection
Intersection of a line
Intersection of a shape
C
Measuring Length and Shape
■ 1. Spatial Measurements Levels
■ 2. Measurements of Linear Objects
■ 3. Measurements of Polygonal Objects
1
Spatial Measurements Levels
■ Qualitative level
• Descriptive classes with no ranking.
• Land cover classes (urban, water, vegetation).
■ Ordinal level
• Qualitative ranking of nominal classes.
• Tree crown sizes (small, medium, or large crowns).
■ Quantitative level
• Ordered values or classes with numeric value.
• Absolute numbers.
• Area of state counties, density.
Spatial Measurements Levels
Line
Each dot represents
500 persons
5
10
15
30 40
Area
50
100
Contour
20
Flow
Population density
Proportional symbols
Ordinal
Quantitative
Point
Qualitative
1
Large
Highway
Medium
Road
High impact
Small
Street
Low impact
Swamp
Town
Q
Road
Boundary
Airport
Desert
River
Forrest
1
Spatial Measurements Levels
■ Classifying Data: Ratios
• Number in one class (fa) over the number of another class (fb).
• Denoted as fa / fb.
• # of males / # of females.
■ Classifying Data: Proportions
• Number in one class (fa) over total in population (N).
• Denoted as fa / N.
• # of males / # of males and females.
2
Measurements of Linear Objects
■ About points
• We can only measure the length of objects have one or more
dimensions.
• Points only have no dimension.
• Impossible the measure the length of points.
■ Lines
•
•
•
•
One dimensional objects.
At least one segment between two points.
Possible to calculate the length of lines.
The more points representing a line, the more accurate will be
the computation of length.
2
Measurements of Linear Objects
2.2
(3,2)
2.2
(1,1)
■ Planar length
•
•
•
•
Length = sum (√((X2-X1)2 + (Y2-Y1)2) for all segments.
Length = √ ((3-1)2 + (2-1)2)) + √ ((5-3)2 + (1-2)2).
Length = √ (4+1) + √ (4 +1)
Length = 4.47
(5,1)
2
Measurements of Linear Objects
Effects of elevation
Straight distance
■ Problems with the geographical space
•
•
•
•
Not a plane.
The real length if often more because of elevation changes.
Must take account of the effects of altitude.
Trigonometric calculation.
• Increase the complexity because of computational and data requirements.
2
Measurements of Linear Objects
True distance (23 miles)
Straight distance (15 miles)
■ Sinuosity
•
•
•
•
•
•
Ratio of the straight-line distance over the true distance.
Also known as the detour index.
Does not describe a specific sinuosity.
An index of 1 would imply no sinuosity.
The smaller the ratio, the more sinuosity.
15 / 23 = 0.65
2
Measurements of Linear Objects
r
■ Radius sinuosity
• Using the radius of a circle.
• The summation of radiuses would define sinuosity.
• No sinuosity would mean an infinite number.
3
Measurements of Polygonal Objects
■ Polygons
• Two dimensional objects.
• More measures are available.
• Perimeter.
• Area.
• Length.
■ Length of polygons
• Orientation of the polygon is important.
• Indication of some geographical process.
• Growth or decline of a glacier.
• Urban growth.
• Forest growth or decline.
3
Measurements of Polygonal Objects
• Major axis
Minor axis
• The axe along the longest part
of the polygon.
• Must divide the polygon in two
equal parts.
Major axis
• Minor axis
• The axe along the shortest part
of the polygon.
• Must divide the polygon in two
equal parts.
2.5
2.5
R=1
3.5
1.5
R = 2.33
• Major axis / Minor axis ratio
• Values higher than 1 denote an
elongated polygon.
• A value of 1 denotes a uniform
polygon.
3
Measurements of Polygonal Objects
■ Perimeter
• Length of all segments in a
closed polygon.
• Length of the contact surface
(exposition) of a feature with
other features.
• Shoreline of a lake.
• Exposition of a forest.
• Building a fence.
Area
■ Area
Perimeter
• A quantitative expression of a
surface.
• Used to compare the
geographical importance of
some attributes.
• A powerful relative value.
3
Measurements of Polygonal Objects
Theory
■ Areas and the geographical
space
• Does not consider the
topography.
• Computation requires a digital
elevation model.
• Dividing the space in triangles
and using trigonometry.
Reality
3
Measurements of Polygonal Objects
■ Centroid
• Point at the exact geographic
center of an area.
• Also known as the center of
gravity.
• When the area is a rectangle or
a circle, the centroid is easy to
find.
C
B
■ Geometric center
• Smallest circle rule.
• Trapezoid rule.
A
D
E
3
Measurements of Polygonal Objects
■ Mean Center
Mean Center
• Find the centroid of a set of
coordinates.
• Each coordinate has the same
importance.
• The average value of X and Y
coordinates.
• C = x/n, y/n
• n is the number of coordinates.
• x and y are the respective
coordinate values.
3
Measurements of Polygonal Objects
■ Weighted Mean Center
Weighted Mean Center
• Find the centroid of a set of
coordinates
• Each coordinate has a different
importance.
• The weighted average value of X
and Y coordinates.
• C = (x*f)/n, (y*f)/n
• n is the number of coordinates.
• f is the weighting factor.
• x and y are the respective
coordinate values.
3
Measurements of Polygonal Objects
■ Spatial integrity
• The level of perforation / fragmentation of a polygon.
• Contiguity:
• An unbroken polygon of a similar feature.
• Perforation:
• A polygon surrounding other polygons (donut effect).
• Fragmentation:
• Polygons of a similar feature surrounded by another polygon.
Perforated polygon
Fragmented polygons
3
Measurements of Polygonal Objects
■ Euler number
EN = 3 - (1-1)
EN = 3
EN = 0 - (3-1)
EN = -2
• Measure of the amount of
perforation and fragmentation in
a region.
• EN = holes – (fragments – 1).
• Positive values are perforated.
• Negative values are fragmented.
3
Measurements of Polygonal Objects
■ Convexity index
Area = 25 sqr miles
Perimeter = 7 miles
CI = 7 / 25 = 0.28
CI = 15 / 25 = 0.60
Area = 25 sqr miles
Perimeter = 15 miles
• CI = Perimeter / Area.
• A perimeter/area ratio is an
expression of the geographical
complexity of a polygon.
• A high ratio means a complex
polygon, while a low ratio means
a simple polygon.
D
Measuring Distance
■ 1. Simple Distance
■ 2. Great Circle Distance
■ 3. Functional Distance
1
Simple Distance
■ Vector data
•
•
•
•
Use Pythagoras.
Accumulate for all segments.
Advantage: Uses ground units.
Disadvantage: Floating point and computational.
■ Raster
•
•
•
•
•
Count pixels.
Track lines and count.
Eliminate redundant pixels and count.
Advantages: Quick.
Disadvantage: Inaccurate.
1
Simple Distance
■ Isotropy of space
• Considers that the characteristics of space are uniform in any
direction.
• Calculated with the Euclidean distance.
2
Great Circle Distance
■ Context
• On a sphere the shortest path between two points is calculated
by the great circle distance.
• An arc linking two points on a sphere.
• Establish the shortest path to use when traveling at the
intercontinental level.
• Shortest route is the one following the curve of the planet, along
the parallels.
• Because of the distortions caused by projections on flat paper a
straight line on a map is not necessarily the shortest distance.
• Ships and aircraft usually fallow the great circle geometry to
minimize distance and save time and money to customers.
2
Great Circle Distance
■ The Great Circle Distance (D) on a sphere
• cos D = (sin a sin b) + (cos a cos b cos |c|)
• a and b are the latitudes of the respective coordinates
• |c| is the absolute value of the difference of longitude between
the respective coordinates.
2
The Great Circle Distance between New York and Moscow
Moscow
55’45”N 37’36”E
New York
40’45”N 73’59”W
Cos (D) = (Sin a Sin b) + (Cos a Cos b Cos |c|)
Sin a = Sin (40.5) = 0.649
Sin b = Sin (55.5) = 0.824
Cos a = Cos (40.5) = 0.760
Cos b = Cos (55.5) = 0.566
Cos c = Cos (73.66 + 37.4) = -0.359
Cos (D) = 0.535 – 0.154 = 0.381
D = 67.631 degrees
1 degree = 111.32 km, so D = 7528.66 km
3
Functional Distance
■ Concept
• Space is not isotropic for most phenomena.
• Absolute barriers.
• Stop movements / interactions completely.
• Mountain ranges.
• Rivers / oceans.
• Relative barriers.
•
•
•
•
Friction that varies according to direction and to features of space.
Slope.
Type of roads.
Border.
3
Absolute and Relative Barriers
Absolute Barrier
A
B
Relative Barrier
A
Low
B
Friction
High
3
Functional Distance: Effect of Topography on Route
Selection
1
c
b
2
Low elevation
Medium elevation
a
High elevation
3
3
Functional Distance (absolute barrier)
1
Sea
a
p1
p2
R (land)
R (sea)
b
2
p1
R2 (land)
a
3
a
p2
R2 (sea)
p3
R (land)
R (sea)
R1 (land)
p4
b
Land
R {C(sea) = C(land)}
R1 (sea)
p4
R1 {C(sea) > C(land)}
R2 {C(sea) < C(land)}
b
R {C(land) > C(sea)}
3
Cost Minimization and Efficiency Maximization
Costs
Low
High
Efficiency
Low
High
Compromise
3
Multi-Criteria Decision-Thinking Process in Route Selection
Route Selection
R=f(C1,C2,C3,C4)
Multi-Criteria Decision
CONSTRAINTS
C1
Physical
C2
Environmental
C3
Economic
C4
Political
Download