Object Relational Model Spatial Queries. Query Model Spatial Layer Data Table where coordinates are stored Primary Filter Spatial Index Index retrieves.

Slides:



Advertisements
Similar presentations
Chapter 4 Part C: Queries, Computations & Map Algebra.
Advertisements

Introdução to Geoinformatics: Geometries. Vector Model Lines: fundamental spatial data model Lines start and end at nodes line #1 goes from node #2 to.
Department of Geoinformation Science Technische Universität Berlin Geo-Databases: lecture 8 Management of Spatial Data Prof. Dr. Thomas H. Kolbe Institute.
Spatial Database Systems. Spatial Database Applications GIS applications (maps): Urban planning, route optimization, fire or pollution monitoring, utility.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Object Relational Model Spatial Queries. Query Model Spatial Layer Data Table where coordinates are stored Primary Filter Spatial Index Index retrieves.
From portions of Chapter 8, 9, 10, &11. Real world is complex. GIS is used model reality. The GIS models then enable us to ask questions of the data by.
Different types of Polygons Simple Convex Simple Concave Non-simple : self-intersecting With holes ConvexConcaveSelf-intersecting.
Spatial Database Systems
Spatial Information Systems (SIS) COMP Spatial queries and operations.
Oracle8i Spatial Concepts. Concepts Geometric data types Oracle8i Spatial data model Spatial Layers Spatial query model Spatial indexing «Window» queries.
Spatial Information Systems (SIS) COMP Spatial access methods: Indexing.
Oracle spatial – Creating spatial tables Object Relational Model Creating Spatial Tables.
Graphics Output Primitives Pixel Addressing and Fill Area Dr. M. Al-Mulhem Feb. 1, 2008.
CS 128/ES Lecture 12a1 Intro to Spatial Analysis (mostly 2D)
TECNOLOGIAS DE ARMAZENAMENTO DE INFORMAÇÃO ESPACIAL.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
Object Relational Model Creating Spatial Tables. Concepts Describe the schema associated with a spatial layer Explain how spatial data is stored using.
Intro. To GIS Lecture 6 Spatial Analysis April 8th, 2013
Introduction to Oracle Spatial
Spatial Database Souhad Daraghma.
Applied Cartography and Introduction to GIS GEOG 2017 EL
Copyright  Oracle Corporation, All rights reserved. GeoInfo June 13, Oracle 8i Extensibility & Spatial Presented By: Jayant Sharma
 Trace the incremental algorithm for constructing convex data on the sample point data given below. Intermediate steps should be shown First, two steps.
6. Simple Features Specification Background information UML overview Simple features geometry.
Exploring ArcToolbox Presented by: Isaac Johnson.
Copyright © 2006 by Maribeth H. Price 7-1 Lesson 7 Spatial Joins.
Tables tables are rows (across) and columns (down) common format in spreadsheets multiple tables linked together create a relational database entity equals.
1 1 W. Fredrick Limp University Professor Robert Harris DBA Center for Advanced Spatial Technologies University of Arkansas Spatially Enabling the DBMS.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Manipulations interpolation/extrapolation line intersections points in polygon line and polygon intersections union/intersection of polygon areas buffering.
1 Spatio-Temporal Predicates Martin Erwig and Markus Schneider IEEE TRANSACTIONS ON KNOWLEDGE AND DATA ENGINEERING Presented by Mamadou Hassimiou Diallo.
Queries Select by Attribute Select by Location. What is a Query? A query extracts information from a data table for further use –Once extracted you can:
Spatial DBMS Spatial Database Management Systems.
Copyright © 2006 by Maribeth H. Price 6-1 Chapter 6 Queries.
Query and Reasoning. Types of Queries Most GIS queries will select spatial features Query by Attribute (Select by Attribute) –Structured Query Language.
NR 143 Study Overview: part 1 By Austin Troy University of Vermont Using GIS-- Introduction to GIS.
Point Pattern Analysis Point Patterns fall between the two extremes, highly clustered and highly dispersed. Most tests of point patterns compare the observed.
Spatial Indexing Techniques Introduction to Spatial Computing CSE 5ISC Some slides adapted from Spatial Databases: A Tour by Shashi Shekhar Prentice Hall.
L1-Spatial Concepts NGEN06 & TEK230: Algorithms in Geographical Information Systems by: Irene Rangel, updated by Sadegh Jamali 1.
1.9 Graphing Calculators: Solving Equations and Inequalities Graphically.
Digital Image Processing Lecture 12: Image Topology (Suppl)
Kedar Gawande Position Paper ITK 478 Fall / 04 / 2006.
Lecture 7 Basic GIS Analysis Operations
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Return to Outline Copyright © 2009 by Maribeth H. Price 5-1 Chapter 5 Queries.
Introduction to Geographic Information Systems Fall 2013 (INF 385T-28620) Dr. David Arctur Research Fellow, Adjunct Faculty University of Texas at Austin.
Intro. To GIS Pre-Lab Spatial Analysis April 1 st, 2013.
Clip versus Overlay Module 4:. Module 3: Project Programs ArcGI S ArcCatalo g ArcMap ArcToolbox.
CENTENNIAL COLLEGE SCHOOL OF ENGINEERING & APPLIED SCIENCE VS 361 Introduction to GIS SPATIAL OPERATIONS COURSE NOTES 1.
Solid Modeling Dr. Scott Schaefer.
Lecture 3: Spatial Data Management Dr. Taysir Hassan Abdel Hamid Associate Professor, Information Systems Dept., Faculty of Computers and Information.
Chapter 8- Queries What are queries? Extract certain records from a map or table Records meet certain criteria –Aspatial queries All parcels with value.
Chapter 6 Spatial Joins.
Chapter 5 Queries.
GIS Analysis Queries Operations Non-spatial Spatial Vector Raster
Physical Structure of GDB
Angle Relationships By Mr. Q.
8-5 Exponential and Logarithmic Equations
Spatial Database Systems
Basic Spatial Analysis
Spatial Analysis and Functions
Query Processing and Optimization
Spatial Data Types And Indexing SQL Server 2008
Introdução to Geoinformatics: vector geometries
Review- vector analyses
Warmup NO CALCULATORS Convert into radians or degrees.
Spatial Database Systems
GTECH 709 Spatial relationships
Basic Spatial Analysis Tools
Presentation transcript:

Object Relational Model Spatial Queries

Query Model Spatial Layer Data Table where coordinates are stored Primary Filter Spatial Index Index retrieves area of interest (window) Reduced Data Set Secondary Filter Spatial Functions Procedures that determine exact relationship Exact Result Set

Spatial Operators vs Functions Spatial operators:Spatial operators: –Take advantage of spatial indexes –Require that spatial index exists on the first geometry specified in the operator. Spatial Functions: Spatial Functions: –Do not take advantage of spatial indexes –Could be used on small tables that are not spatially indexed Spatial operators:Spatial operators: –Take advantage of spatial indexes –Require that spatial index exists on the first geometry specified in the operator. Spatial Functions: Spatial Functions: –Do not take advantage of spatial indexes –Could be used on small tables that are not spatially indexed

Spatial Operators vs Functions SDO_RELATE –Performs a primary and secondary filter SDO_WITHIN_DISTANCE –Gets all geometries that are within some distance from a selected geometry SDO_NN –Gets the ‘n’ closest geometries SDO_RELATE –Performs a primary and secondary filter SDO_WITHIN_DISTANCE –Gets all geometries that are within some distance from a selected geometry SDO_NN –Gets the ‘n’ closest geometries SDO_GEOM.RELATE –To determine the relationship between two geometries –To perform a spatial query without using a spatial index (I.e. on a small table) SDO_GEOM.WITHIN_DISTANCE –Generates a buffer around a geometry and performs a secondary filter OperatorsFunctions

Spatial Operators

The SDO_RELATE operator boolean := SDO_RELATE (,, ‘MASK= QUERYTYPE= [other optional parameters]’ ) boolean := SDO_RELATE (,, ‘MASK= QUERYTYPE= [other optional parameters]’ ) Performs an exact query (primary and secondary filter) Returns TRUE or FALSE Performs an exact query (primary and secondary filter) Returns TRUE or FALSE

Required arguments GEOMETRY-1 –A column of type SDO_GEOMETRY GEOMETRY-2 –Variable or column of type SDO_GEOMETRY MASK –Identify spatial relationship to test QUERYTYPE –Valid values are JOIN or WINDOW GEOMETRY-1 –A column of type SDO_GEOMETRY GEOMETRY-2 –Variable or column of type SDO_GEOMETRY MASK –Identify spatial relationship to test QUERYTYPE –Valid values are JOIN or WINDOW

A B A B A B A B A B A red B green A B B Inside A A Contains B B Covered by A A Covers B Touch Overlap Boundaries Intersect Overlap Boundaries Disjoint Equal Disjoint Spatial (topological) relationships

Topological relationships 1. DISJOINT: boundaries and interiors do not intersect 2. TOUCH: boundaries intersect but interiors do not intersect 3. OVERLAPBDYDISJOINT: interior of one object intersects boundary and interior of other object, but two boundaries do not intersect (example: a line originates outside a polygon and ends inside the polygon) 4. OVERLAPBDYINTERSECT: boundaries and interiors of the two objects intersect 5. EQUAL: the two objects have the same boundary and interior 6. CONTAINS: interior and boundary of one object is completely contained in the interior of other object 7. COVERS: interior of one object is completely contained in interior of other object and their boundaries intersect 8. INSIDE: opposite of CONTAINS. A INSIDE B implies B CONTAINS A. 9. COVEREDBY: opposite of COVERS. A COVEREDBY B implies B COVERS A. 10. ANYINTERACT: the objects are non-disjoint 1. DISJOINT: boundaries and interiors do not intersect 2. TOUCH: boundaries intersect but interiors do not intersect 3. OVERLAPBDYDISJOINT: interior of one object intersects boundary and interior of other object, but two boundaries do not intersect (example: a line originates outside a polygon and ends inside the polygon) 4. OVERLAPBDYINTERSECT: boundaries and interiors of the two objects intersect 5. EQUAL: the two objects have the same boundary and interior 6. CONTAINS: interior and boundary of one object is completely contained in the interior of other object 7. COVERS: interior of one object is completely contained in interior of other object and their boundaries intersect 8. INSIDE: opposite of CONTAINS. A INSIDE B implies B CONTAINS A. 9. COVEREDBY: opposite of COVERS. A COVEREDBY B implies B COVERS A. 10. ANYINTERACT: the objects are non-disjoint

select c.city, c.pop90 from cities c where sdo_relate ( c.location, mdsys.sdo_geometry (2003, null, null, mdsys.sdo_elem_info_array (1,1003,3), mdsys.sdo_ordinate_array (-109,37,-102,40)), 'mask=ANYINTERACT') = 'TRUE'; select c.city, c.pop90 from cities c where sdo_relate ( c.location, mdsys.sdo_geometry (2003, null, null, mdsys.sdo_elem_info_array (1,1003,3), mdsys.sdo_ordinate_array (-109,37,-102,40)), 'mask=ANYINTERACT') = 'TRUE'; SDO_RELATE - A window query Find all cities in a selected rectangular area

select c.county, c.state_abrv from counties c, states s where s.state = 'New Hampshire' and sdo_relate (c.geom, s.geom, 'mask=INSIDE+COVEREDBY querytype=WINDOW') = 'TRUE'; select c.county, c.state_abrv from counties c, states s where s.state = 'New Hampshire' and sdo_relate (c.geom, s.geom, 'mask=INSIDE+COVEREDBY querytype=WINDOW') = 'TRUE'; SDO_RELATE - A window query Find all counties in the state of New Hampshire

select c1.county, c1.state_abrv from counties c1, counties c2 where c2.state = 'New Jersey' and c2.county = 'Passaic' and sdo_relate (c1.geom, c2.geom, 'mask=TOUCH querytype=WINDOW') = 'TRUE'; select c1.county, c1.state_abrv from counties c1, counties c2 where c2.state = 'New Jersey' and c2.county = 'Passaic' and sdo_relate (c1.geom, c2.geom, 'mask=TOUCH querytype=WINDOW') = 'TRUE'; SDO_RELATE - Another window query Find all counties around county Passaic

create or replace function population_in_rectangle (Xmin number, Ymin number, Xmax number, Ymax number) return number as rectangle mdsys.sdo_geometry; total_population number; begin rectangle := mdsys.sdo_geometry (2003, null, null, mdsys.sdo_elem_info_array (1,1003,3), mdsys.sdo_ordinate_array (Xmin, Ymin, Xmax, Ymax)); select sum(c.totpop) into total_population from counties c where sdo_relate (c.geom,rectangle, 'mask=ANYINTERACT') = 'TRUE'; return total_population; end; create or replace function population_in_rectangle (Xmin number, Ymin number, Xmax number, Ymax number) return number as rectangle mdsys.sdo_geometry; total_population number; begin rectangle := mdsys.sdo_geometry (2003, null, null, mdsys.sdo_elem_info_array (1,1003,3), mdsys.sdo_ordinate_array (Xmin, Ymin, Xmax, Ymax)); select sum(c.totpop) into total_population from counties c where sdo_relate (c.geom,rectangle, 'mask=ANYINTERACT') = 'TRUE'; return total_population; end; SDO_RELATE and PL/SQL Find total population in a selected rectangular area

SDO_RELATE - join vs window query Find all interstates that cross county Passaic in NJ Find all interstates that cross a county in Arizona with pop density <10 This requires compatible indexes on the layers ! Find all interstates that cross county Passaic in NJ Find all interstates that cross a county in Arizona with pop density <10 This requires compatible indexes on the layers ! select i.interstate from interstates i, counties c where c.state = 'New Jersey' and c.county = ‘Passaic’ and sdo_relate (i.geom, c.geom, 'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'; select i.interstate from interstates i, counties c where c.state = 'New Jersey' and c.county = ‘Passaic’ and sdo_relate (i.geom, c.geom, 'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'; select i.interstate from interstates i, counties c where c.state = 'Arizona' and c.poppsqmi < 10 and sdo_relate (i.geom, c.geom, 'mask=ANYINTERACT querytype=JOIN') = 'TRUE'; select i.interstate from interstates i, counties c where c.state = 'Arizona' and c.poppsqmi < 10 and sdo_relate (i.geom, c.geom, 'mask=ANYINTERACT querytype=JOIN') = 'TRUE';

Optional arguments IDXTAB1 –Index table to associate with first geometry in operator. –By default, the primary index table is used. IDXTAB2 –Index table to associate with the second geometry in operator –By default, the primary index table is used. –Only supported if QUERYTYPE=JOIN IDXTAB1 –Index table to associate with first geometry in operator. –By default, the primary index table is used. IDXTAB2 –Index table to associate with the second geometry in operator –By default, the primary index table is used. –Only supported if QUERYTYPE=JOIN

The SDO_WITHIN_DISTANCE operator boolean := SDO_WITHIN_DISTANCE (,, ‘DISTANCE=, QUERYTYPE= [other optional parameters]’ ) boolean := SDO_WITHIN_DISTANCE (,, ‘DISTANCE=, QUERYTYPE= [other optional parameters]’ ) Performs an exact or approximate query Euclidean distance only Returns TRUE or FALSE Performs an exact or approximate query Euclidean distance only Returns TRUE or FALSE

Arguments GEOMETRY-1 –A column of type SDO_GEOMETRY GEOMETRY-2 –Variable or column of type SDO_GEOMETRY DISTANCE (required) –The distance (expressed in the units used for the coordinate system) QUERYTYPE (optional) GEOMETRY-1 –A column of type SDO_GEOMETRY GEOMETRY-2 –Variable or column of type SDO_GEOMETRY DISTANCE (required) –The distance (expressed in the units used for the coordinate system) QUERYTYPE (optional)

Find all cities within a distance from an interstate Find interstates within a distance from a city Find all cities within a distance from an interstate Find interstates within a distance from a city select c.city, c.state_abrv from cities c, interstates i where highway = ‘I4’ and sdo_within_distance ( c.location, i.geom,‘distance=0.5') = 'TRUE'; select c.city, c.state_abrv from cities c, interstates i where highway = ‘I4’ and sdo_within_distance ( c.location, i.geom,‘distance=0.5') = 'TRUE'; SDO_WITHIN_DISTANCE Examples select i.highway from interstates i, cities c where city = 'Tampa' and sdo_within_distance ( i.geom, c.location,'distance=0.5') = 'TRUE'; select i.highway from interstates i, cities c where city = 'Tampa' and sdo_within_distance ( i.geom, c.location,'distance=0.5') = 'TRUE';

Find all cities within a distance from a state Also returns all cities in Florida ! Find all cities within a distance from a state Also returns all cities in Florida ! select c.city, c.state_abrv from cities c, states s where s.state='Florida' and sdo_within_distance ( c.location, s.geom, 'distance=1.5') = 'TRUE'; select c.city, c.state_abrv from cities c, states s where s.state='Florida' and sdo_within_distance ( c.location, s.geom, 'distance=1.5') = 'TRUE'; SDO_WITHIN_DISTANCE Examples

The SDO_NN operator boolean := SDO_NN (,, ‘SDO_NUM_RES=, [other optional parameters]’ ) boolean := SDO_NN (,, ‘SDO_NUM_RES=, [other optional parameters]’ ) Returns the N closest geometries Euclidean distance only Returns TRUE or FALSE Returns the N closest geometries Euclidean distance only Returns TRUE or FALSE

Arguments GEOMETRY-1 –A column of type SDO_GEOMETRY GEOMETRY-2 –Variable or column of type SDO_GEOMETRY SDO_NUM_RES (required) –Number of objects to select GEOMETRY-1 –A column of type SDO_GEOMETRY GEOMETRY-2 –Variable or column of type SDO_GEOMETRY SDO_NUM_RES (required) –Number of objects to select

Find the 5 nearest cities from Orlando select c1.city, c1.state_abrv from cities c1, cities c2 where c2.city = 'Orlando' and sdo_nn ( c1.location, c2.location, 'sdo_num_res = 6') = 'TRUE' and c1.rowid <> c2.rowid; select c1.city, c1.state_abrv from cities c1, cities c2 where c2.city = 'Orlando' and sdo_nn ( c1.location, c2.location, 'sdo_num_res = 6') = 'TRUE' and c1.rowid <> c2.rowid; SDO_NN Example

Find the 10 nearest cities from Orlando ordered by distance select c1.city, c1.state_abrv, sdo_geom.sdo_distance ( c1.location, c2.location, 0.005) distance from cities c1, cities c2 where c2.city = 'Orlando' and sdo_nn ( c1.location, c2.location, 'sdo_num_res = 11') = 'TRUE' and c1.rowid <> c2.rowid order by distance; select c1.city, c1.state_abrv, sdo_geom.sdo_distance ( c1.location, c2.location, 0.005) distance from cities c1, cities c2 where c2.city = 'Orlando' and sdo_nn ( c1.location, c2.location, 'sdo_num_res = 11') = 'TRUE' and c1.rowid <> c2.rowid order by distance; SDO_NN Example