490 likes | 509 Views
Learn about querying features of a spatial database, using spatial attributes, length and shape measurement techniques. Discover basic operators, boolean search, and successive search methods. Enhance your spatial data querying skills.
E N D
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
1 What is Querying? • Narrowing down information • A GIS is composed of a database. • Spatial attributes linked to their features. • Most GIS have a huge list of records. • 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. Records GIS Database Query Relevant records Query results
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 Operator: 23 23 47 47 Age < 30 19 19 35 35
1 What is Querying? • Search space • Set of all records in a database. • Information over which a query is performed. • Search result • Set of all records that satisfy a query. • All records that are True. • A search result can become a search space. Search space “False” records Search results “True” records “False” records Search results “True” records
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 Set A Set B Pacific Coast California AND
3 Boolean Operators Set A OR Set B California Nevada
3 Boolean Operators NOT California Set A Set B Los Angeles
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.
4 Successive Query Query Selected Records Records New Set Selected Records Selected Records Add to Set Selected Records Selected Records Select from Set
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.
Point Line Area 30 40 50 Each dot represents 500 persons 100 Contour 15 Quantitative 10 20 5 Flow Population density Proportional symbols Large Highway Ordinal High impact Medium Road Street Low impact Small Swamp Town Road Boundary Desert Qualitative Q Airport River Forrest 1 Spatial Measurements Levels
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 • 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 (3,2) 2.2 2.2 (5,1) (1,1)
2 Measurements of Linear Objects • 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. Effects of elevation Straight distance
2 Measurements of Linear Objects True distance (23 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 Straight distance (15 miles)
2 Measurements of Linear Objects • Radius sinuosity • Using the radius of a circle. • The summation of radiuses would define sinuosity. • No sinuosity would mean an infinite number. r
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 • The axe along the longest part of the polygon. • Must divide the polygon in two equal parts. • Minor axis • The axe along the shortest part of the polygon. • Must divide the polygon in two equal parts. • Major axis / Minor axis ratio • Values higher than 1 denote an elongated polygon. • A value of 1 denotes a uniform polygon. Minor axis Major axis 2.5 2.5 R = 1 3.5 1.5 R = 2.33
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 • A quantitative expression of a surface. • Used to compare the geographical importance of some attributes. • A powerful relative value. Area Perimeter
3 Measurements of Polygonal Objects • Areas and the geographical space • Does not consider the topography. • Computation requires a digital elevation model. • Dividing the space in triangles and using trigonometry. Theory Reality
C B A D E 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. • Geometric center • Smallest circle rule. • Trapezoid rule.
3 Measurements of Polygonal Objects • 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. Mean Center
3 Measurements of Polygonal Objects • 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. Weighted Mean Center
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. Fragmented polygons Perforated polygon
3 Measurements of Polygonal Objects • Euler number • Measure of the amount of perforation and fragmentation in a region. • EN = holes – (fragments – 1). • Positive values are perforated. • Negative values are fragmented. EN = 3 - (1-1) EN = 3 EN = 0 - (3-1) EN = -2
3 Measurements of Polygonal Objects • Convexity index • 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. Area = 25 sqr miles Perimeter = 7 miles CI = 7 / 25 = 0.28 CI = 15 / 25 = 0.60 Area = 25 sqr miles Perimeter = 15 miles
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 B Low High Friction
3 Functional Distance: Effect of Topography on Route Selection 1 c b 3 2 a Low elevation High elevation Medium elevation
3 Functional Distance (absolute barrier) Sea 1 2 3 R2 (land) a a a p1 p1 R (land) p2 p2 R (land) R2 (sea) p3 R (sea) R (sea) R1 (land) b b b p4 p4 Land R1 (sea) R1 {C(sea) > C(land)} R2 {C(sea) < C(land)} R {C(land) > C(sea)} R {C(sea) = C(land)}
3 Cost Minimization and Efficiency Maximization Efficiency Compromise Costs Low High Low High
3 Multi-Criteria Decision-Thinking Process in Route Selection Multi-Criteria Decision Route Selection R=f(C1,C2,C3,C4) CONSTRAINTS C1 Physical C2 Environmental Economic C3 Political C4