23
Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd a, counties_tig2000 b WHERE b.ID = 72 and (MDSYS.SDO_RELATE(a.GEOMETRY, b.GEOMETRY, 'mask=ANYINTERACT querytype = WINDOW') = 'TRUE'); SELECT geometry FROM counties_tig2000 WHERE id = 72;

Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Embed Size (px)

Citation preview

Page 1: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Introduction to Oracle Spatial

Spatial Database

SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd a, counties_tig2000 b WHERE b.ID = 72 and (MDSYS.SDO_RELATE(a.GEOMETRY, b.GEOMETRY, 'mask=ANYINTERACT querytype = WINDOW') = 'TRUE');

SELECT geometry FROM counties_tig2000 WHERE id = 72;

Page 2: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Oracle Spatial

Oracle Spatial consists of a set of functions and procedures, built into the database software, that enables spatial data to be stored, accessed, and analyzed.

•Oracle Spatial uses the Oracle object-relational model for representing geometries.•The geometry of a spatial element is stored as an object, in a single row, in a single column of type SDO_GEOMETRY. A single table will hold all of the geometries and attributes of a layer.•The SDO_GEOMETRY object supports many geometry types, including points, line strings, polygons, arc line strings, arc polygons, compound polygons, compound line strings, circles, and rectangles

3 Baxter 05003 Geometry object

4 Benton 05005 Geometry object

… … … …

Spatial database table “Counties_tig2000”

id county fips geometry

Benton county

Page 3: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOMETRY

The object type SDO_GEOMETRY as:

CREATE TYPE sdo_geometry AS OBJECT ( SDO_GTYPE NUMBER, SDO_SRID NUMBER, SDO_POINT SDO_POINT_TYPE, SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY, SDO_ORDINATES SDO_ORDINATE_ARRAY);

CREATE TYPE sdo_point_type AS OBJECT ( X NUMBER, Y NUMBER, Z NUMBER);

CREATE TYPE sdo_elem_info_array AS VARRAY (1048576) OF NUMBER;

CREATE TYPE sdo_ordinate_array AS VARRAY (1048576) OF NUMBER;

SDO_GTYPE: type of geometry in format DLTT Dimensions (2,3 or 4) Linear Reference measure dimension (which dimension (3 or 4) contains the measure value) TT geometry type (01 – point, 02 – line, 03 – polygon)

Example: 2003 indicates a two-dimensional polygon

SDO_SRID: Identity of the spatial coordinate system

Example: 8265 indicates Longitude / Latitude (NAD 83)

SDO_POINT: X Y and Z values of a point

SDO_ELEM_INFO: Lets you know how to interpret the ordinates stored in the SDO_ORDINATES object. Contains one or more sets of triplets. Each triplet set is interpreted as: SDO_STARTING_OFFSET: Offset in the sdo_ordinate array SDO_ETYPE: Type of element SDO_INTERRETATION: Defines either the number of triplet values that are part of a compound element or how the sequence of ordinates for the non-compound element is interpreted

SDO_ORDINATES: The coordinate values that make up the boundary of a spatial object

Page 4: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

3 Baxter 05003 Geometry object

4 Benton 05005 Geometry object

… … … …

Id county fips geometryCounties_tig2000 table

SDO_GTYPE SDO_SRID SDO_POINT SDO_ELEM_INFO SDO_ORDINATES

2003 8265 NULL 1, 1003, 1 -94.33516, 36.170734, -94.334992, 36.176756, -94.334936, 36.17877, …, …

SDO_GEOMETRY Object

Benton county

•SDO_GTYPE 2003 2 dimensional geometry with one polygon•SDO_SRID 8265 identify a coordinate system -- long / Lat (NAD 83)

•SDO_POINT NULL X, Y, and Z of point geometry•SDO_ELEM_INFO

SDO_STARTING_OFFSET 1 starting point of ordinates SDO_ETYPE 1003 exterior simple polygon ringSDO_INTERPRETATION 1 polygon boundary made up of a

sequence of connecting straight line segments•SDO_ORDINATES -94.33516, 36.170734, … coordinate boundaries of the geometry (1429)

SDO_GEOMETRY Example

Page 5: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOMETRY Example

----Create a simple table with a spatial column—---------------------------------------------------------------DROP TABLE TEMPBOX;CREATE TABLE TEMPBOX ( ID NUMBER, GEOMETRY SDO_GEOMETRY);

--Insert a simple polygon data type into the table--INSERT INTO TEMPBOX VALUES ( 1, MDSYS.SDO_GEOMETRY(2003, 8265, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1), MDSYS.SDO_ORDINATE_ARRAY(-94.38,36.26, -94.15,36.26, -94.15, 36.14, -94.38,36.14, -94.38,36.26)));

-------------------------------------------------------------------Insert table dimensional information----------------DELETE FROM USER_SDO_GEOM_METADATA WHERE TABLE_NAME = 'TEMPBOX';INSERT INTO USER_SDO_GEOM_METADATA VALUES ('TEMPBOX', 'GEOMETRY', MDSYS.SDO_DIM_ARRAY(MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.0000005), MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.0000005)),8265);

------------------------------------------------------------------Create a spatial index on the geometry column--DROP INDEX IS_TEMPBOX;CREATE INDEX IS_TEMPBOX ON TEMPBOX(GEOMETRY) INDEXTYPE IS MDSYS.SPATIAL_INDEX;

Page 6: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

The Query Model

Oracle Spatial uses a two-tier query model to resolve spatial queries and spatial joins. The two-tiered model uses two distinct operations, the primary and secondary filter.

•The secondary filter applies exact computations to the geometries that pass from the primary filter.

•The Primary filter compares geometry approximations (Spatial Indexes) then passes that along to the secondary filter.

Large Input Data SetPrimary

Filter

Small Candidate

Set

Secondary Filter

Exact Result

Set

Page 7: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Spatial OperatorsSpatial operators are used to perform proximity analysis between geometry objects. Like relational operators (<, >, =) spatial operators can be used in the “WHERE” clause of a regular SQL statement.

Operators:SDO_FILTER: Specifies which geometries may interact with a given geometry. This Operator performs only the primary filter operation.

SDO_RELATE: Determines whether, or not, two geometries interact in a specific way. This operator performs both primary and secondary filter operations.

SDO_NN: Determines the nearest neighbor geometries to a geometry.SDO_NN_DISTANCE: Returns the distance of an object returned by the SDO_NN operator. (Ancillary operator of SDO_NN)

SDO_WITHIN_DISTANCE: Determines if two geometries are within a specified distance from one another.

Page 8: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Spatial Operator Examples

SELECT a.geometry FROM public_schools_k12_src a, counties_tig2000 b WHERE b.abname = 'Washington County' AND SDO_FILTER(a.geometry,b.geometry) = 'TRUE'

Find all of the schools that match the minimum bounding rectangle of Washington county

False Positive

SDO_FILTER: Specifies which geometries may interact with a given geometry. This Operator performs only the primary filter operation.

Format SDO_FILTER(table_geometry, query_geometry)Parameters table_geometry: sdo_geometry column in a table (must be spatially indexed) query_geometry: sdo_geometry column in a table or transient instance of a geometryReturns ‘TRUE’ if geometry objects Minimum Bounding Rectangle are non-disjoint

Page 9: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Spatial Operator Examples

SDO_RELATE: Find all of the schools in Washington county that match the county geometry exactly.

SELECT a.geometry FROM public_schools_k12_src a, counties_tig2000 b WHERE b.abname = 'Washington County' AND SDO_RELATE(a.geometry,b.geometry,'mask=ANYINTERACT') = 'TRUE'

SDO_RELATE: Determines whether, or not, two geometries interact in a specific way. This operator performs both primary and secondary filter operations.

Format SDO_RELATE(table_geometry, query_geometry, parameters)Parameters table_geometry: sdo_geometry column in a table (must be spatially indexed) query_geometry: sdo_geometry column in a table or transient instance of a geometry parameters: mask keyword to specify the topological relationship Valid mask: TOUCH, OVERLAPBDYDISJOINT, OVERLAPBDYINTERSECT, EQUAL, INSIDE, COVEREDBY, CONTAINS, COVERS, ANYINTERACT, ONReturns ‘TRUE’ if geometry objects have the topological relationship specified by the mask keyword

Page 10: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Spatial Operator Examples

SDO_NN: Determines the nearest neighbor geometries to a geometry.

Format SDO_NN(table_geometry, query_geometry, parameters[, number])Parameters table_geometry: sdo_geometry column in a table (must be spatially indexed) query_geometry: sdo_geometry column in a table or transient instance of a geometry parameters: keyword that determines the behavior of the operator Valid keywords: sdo_batch_size: The number of rows to be evaluated at a time when the SDO_NN expression may need to be evaluated multiple times to satisfy the WHERE clause sdo_num_res: specifies the number of results to be returned unit: used with SDO_NN_DISTANCE operator as a tag to bind the two operators Returns Object from the table_geometry that are nearest to the query_geometry

SDO__NN: Find the 5 closest schools to Bob’s house.

SELECT a.geometry FROM public_schools_k12_src a WHERE SDO_NN(a.geometry, MDSYS.SDO_GEOMETRY(2001, 8265, MDSYS.SDO_POINT_TYPE(- 94.2465, 35.9785, NULL), NULL,NULL), 'SDO_NUM_RES=5') = 'TRUE'

Page 11: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_NN_DISTANCE: What is the distance to the 5 closest schools to Bob’s house?

SELECT a.NAME,SDO_NN_DISTANCE(1) FROM public_schools_k12_src a WHERE SDO_NN(A.GEOMETRY, MDSYS.SDO_GEOMETRY(2001,8265, MDSYS.SDO_POINT_TYPE(-94.2465, 35.9785, NULL) ,NULL,NULL), 'SDO_NUM_RES=5', 1) = 'TRUE' ORDER BY 2;

SCHOOL DistancePRAIRIE GROVE HIGH 6411.59039PRAIRIE GROVE JUNIOR HIGH 6411.59039PRAIRIE GROVE LOWER ELEM.6649.8313GREENLAND ELEM SCHOOL 6757.65032GREENLAND HIGH SCHOOL 6757.65032

SDO_NN_DISTANCE: Returns the distance of an object returned by the SDO_NN operator.

Spatial Operator Examples

Format SDO_NN_DISTANCE(number)Parameters number: used with SDO_NN operator as a tag to bind the two operators Returns The distance (in meters for geodetic data) of an object returned by SDO_NN

Page 12: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Spatial Operator Examples

SDO_WITHIN_DISTANCE: Determines if two geometries are within a specified distance from one another.

Format SDO_WITHIN_DISTANCE(table_geometry, query_geometry, parameters)Parameters table_geometry: sdo_geometry column in a table (must be spatially indexed) query_geometry: sdo_geometry column in a table or transient instance of a geometry parameters: keyword that determines the behavior of the operator Valid keywords: distance: Distance value in meters for geodetic data or as defined in the unit parameter may need to be evaluated multiple times to satisfy the WHERE clause unit: unit of measurement default is meters querytype: ‘FILTER’ keyword for only primary filter operationReturns Object from the table_geometry that is within specified distance of the object in the query_geometry

SDO_WITHIN_DISTANCE: What school district boundaries are within 10 miles of Bob’s house?

SELECT a.name "Public School Districts" FROM public_school_districts_src a WHERE SDO_WITHIN_DISTANCE(a.geometry, (MDSYS.SDO_GEOMETRY(2001,8265,

MDSYS.SDO_POINT_TYPE(-94.2465,35.9785,NULL), NULL,NULL)), 'DISTANCE = 10 UNIT = MILE') = 'TRUE';

Public School DistrictsLincolnPrairie GroveWest ForkSpringdaleFarmingtonFayettevilleGreenlandWinslowGreenlandElkins

Page 13: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Geometric Analysis Functions

Geometry functions in Oracle Spatial can be grouped into the following categories:

Single-Object operations:

SDO_ARC_DENSITY: Returns a geometry in which each arc or circle in the input geometry is changed into an approximation of an arc or circle consisting of straight line segments (NOTE: Some GIS software only supports simple geometry features (points, lines and polygons).

SDO_AREA: Computes the area of a two dimensional polygon.

SDO_BUFFER: Generates a buffer polygon around a geometry.

SDO_CENTROID: Returns the centroid (center of mass or gravity) of a polygon.

SDO_CONVEXHULL: Returns a polygon object that represents the convex hull of a geometry object (Shrink-wrap the geometry).

SDO_LENGTH: Computes the length or perimeter of a geometry.

SDO_MBR: Returns the minimum bounding rectangle of a geometry.

SDO_POINTONSURFACE: Returns a point that is guaranteed to be on the surface of a polygon.

SDO_MIN_MBR_ORDINATE: Returns the minimum value of the specified ordinate of the minimum bounding rectangle of a geometry (min(X) or min(Y)).

SDO_MAX_MBR_ORDINATE: Returns the maximum value of the specified ordinate of the minimum bounding rectangle of a geometry (max(X) or max(Y)).

Page 14: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Geometry Functions

Two-Object Operations:

SDO_DIFFERENCE: Returns a geometry object that is the topological difference (MINUS operation) of two geometry objects.

SDO_DISTANCE: Computes the distance between two geometry objects.

SDO_INTERSECTION: Returns a geometry object that is the topological intersection (AND operation) of two geometry objects.

SDO_UNION: Returns a geometry object that is the topological union (OR operation) of two geometry objects.

SDO_XOR: Returns a geometry object that is the topological symmetric difference (XOR operation) of two geometry objects.

Validation Operations:

SDO_VALIDATE_GEOMETRY: Determines if a geometry is valid (row level check).

SDO_VALIDATE_LAYER: Determines if all geometries stored in a column are valid (table level check).

A B

BA

BA

A B

Page 15: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Geometry Functions

Spatial Aggregate Functions:

SDO_AGGR_CENTROID: Returns the geometry object that is the center-of-gravity of multiple geometry object.

SDO_AGGR_CONVEXHULL: Returns the geometry object that is the convex hull of multiple geometry object.

SDO_AGGR_MBR: Returns the minimum bounding rectangle of multiple geometry object.

SDO_AGGR_UNION: Returns the geometry object that is the topological union of multiple geometry object.

Page 16: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOM.SDO_AREA: What are the sizes of the school districts in Washington County.

SELECT SDO_GEOM.SDO_AREA(a.geometry, 0.0005, 'UNITS = SQ_MILE') "Size", a.name FROM public_school_districts_src a, counties_tig2000 b WHERE b.abname = 'Washington County' and SDO_FILTER(a.geometry,b.geometry) = 'TRUE' ORDER by 2;

Size NAME

-------------- -------------------151.642321 Cedarville101.280977 Elkins32.9321684 Farmington113.541157 Fayetteville86.7219756 Gentry135.643985 Greenland74.1132046 Greenland740.479142 Huntsville488.251756 Huntsville146.224995 Lincoln 196.57418 Mountainburg304.955565 Ozark329.734769 Ozark 105.52943 Prairie Grove259.682501 Rogers 144.4364 Siloam Springs184.059404 Springdale 252.21372 St. Paul131.281055 West Fork 61.529816 Winslow

SDO_GEOM.SDO_AREA: Computes the area of a two dimensional polygon.

Format SDO_GEOM.SDO_AREA(geometry, tolerance, unit_params)Parameters geometry: The geometry object to be analyzed tolerance: Tolerance used in analyzsis unit_params: units of the return value Returns Area of a geometry object (polygon)

Geometric Analysis Examples

Page 17: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOM.SDO_LENGTH: How many miles of State highways are in Washington County?

State Hwy in Washington Co-------------------------- 219.587073

SDO_GEOM.SDO_LENGTH: Computes the length or perimeter of a geometry.

Format SDO_GEOM.SDO_LENGTH(geometry, tolerance, unit_params)Parameters geometry: The geometry object to be analyzed tolerance: Tolerance used in analyzsis unit_params: units of the return value Returns Length of a line geometry object or perimeter of a polygon

Geometric Analysis Examples

SELECT SUM(SDO_GEOM.SDO_LENGTH(a.geometry, 0.0005, 'UNITS = MILE')) "State Hwy in Washington Co" FROM state_hwy_all_ahtd a, counties_tig2000 b WHERE b.abname = 'Washington County' and SDO_RELATE(a.geometry,b.geometry,'MASK=ANYINTERACT') = 'TRUE';

Page 18: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOM.SDO_BUFFER: What are the two mile buffer zones around Prairie Grove and Farmington.

SDO_GEOM.SDO_BUFFER: Generates a buffer polygon around or inside a geometry object.

Format SDO_GEOM.SDO_BUFFER(geometry, tolerance, distance[, parameters])Parameters geometry: The geometry object to be analyzed tolerance: Tolerance used in analysis distance: units of the return value parameters: units and arc_tolerance keywordsReturns Buffer geometry

Geometric Analysis Examples

SELECT SDO_GEOM.SDO_BUFFER(a.geometry, 2.0, 0.0005, 'UNIT=MILE' )FROM city_limits2003_ahtd aWHERE a.city_name = 'Prairie Grove' or a.city_name = 'Farmington'

Page 19: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOM.SDO_CENTROID: Returns the centroid (center of mass or gravity) of a polygon.

SDO_GEOM.SDO_POINTONSURFACE: Returns a point that is guaranteed to be on the surface of a polygon.

SDO_GEOM.SDO_CENTROID: Where do I put the label?

Format SDO_GEOM.SDO_CENTROID(geometry, tolerance) SDO_GEOM.SDO_POINTONSURFACE(geometry, tolerance)Parameters geometry: The geometry object to be analyzed tolerance: Tolerance used in analyzsisReturns geometry

Geometric Analysis Examples

SELECT SDO_GEOM.SDO_CENTROID(a.geometry, 0.0005)FROM city_limits2003_ahtd aWHERE a.city_name = 'Prairie Grove'

NOTE: SDO_CENTROID does note always put the center of mass inside the polygon. A shape like a cresant moon would have the centroid placed outside the polygon. SDO_POINTONSURFACE the geometry is always on the polygon.

Page 20: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOM.SDO_MBR: Returns the minimum bounding rectangle of a geometry.

SDO_GEOM.SDO_MIN_MBR_ORDINATE: Returns the minimum value of the specified ordinate of the minimum bounding rectangle of a geometry (min(X) or min(Y)).SDO_GEOM.SDO_MAX_MBR_ORDINATE: Returns the maximum value of the specified ordinate of the minimum bounding rectangle of a geometry (max(X) or max(Y)).

Geometric Analysis Examples

Format SDO_GEOM.SDO_MBR(geometry[, dim]) SDO_GEOM.SDO_MIN_MBR_ORDINATE(geometry,ordinate_pos) SDO_GEOM.SDO_MIN_MBR_ORDINATE(geometry,ordinate_pos)Parameters geometry: The geometry object to be analyzed Dim: Dimensional information ordinate_pos: Y = 1, X = 2 Returns geometry number number

SELECT SDO_GEOM.SDO_MBR(a.geometry) FROM city_limits2003_ahtd a WHERE a.city_name = 'Prairie Grove'

Page 21: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_GEOM.SDO_CONVEXHULL: Produce simplified geometry of Fayetteville city limits.

Format SDO_GEOM.SDO_CONVEXHULL(geometry, tolerance)Parameters geometry: The geometry object to be analyzed tolerance: Tolerance used in analysisReturns geometry

Geometric Analysis Examples

SELECT SDO_GEOM.SDO_CONVEXHULL(a.geometry,0.0005) FROM city_limits2003_ahtd a WHERE a.city_name = 'Fayetteville'

SDO_CONVEXHULL: Returns a polygon object that represents the convex hull of a geometry object (Shrink-wrap the geometry). Often used to simplify complex geometries.

Page 22: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

Geometry Function ExampleTwo-Object Operations

SDO_INTERSECTION: Returns a geometry object that is the topological intersection (AND operation) of two geometry objects.

A B

Format SDO_GEOM.SDO_INTERSECTION(geometry1, geometry2, tolerance)Parameters geometry1: geometry object geometry2: geometry object tolerance:Returns geometry shared by the two geometries

What is the area of overlap between two polygon geometries?

SELECT sdo_geom.sdo_intersection(b.geometry, a.geometry, 0.00005) FROM counties_tig2000 a, tempbox b WHERE a.abname = 'Washington Counties' and b.id = 1

SELECT sdo_geom.sdo_intersection(b.geometry, a.geometry, 0.00005) FROM adt2000_ahtd a, tempbox b WHERE b.ID = 1 and (MDSYS.SDO_RELATE(a.GEOMETRY, b.GEOMETRY, 'mask=ANYINTERACT') = 'TRUE')

What is the area of overlap between a polygon geometry and a line geometry?

Page 23: Introduction to Oracle Spatial Spatial Database SELECT SDO_GEOM.SDO_INTERSECTION(b.geometry, a.geometry, 0.000000005) as geometry FROM state_hwy_all_ahtd

SDO_DISTANCE: Computes the distance between two geometry objects.

Geometry Function ExampleTwo-Object Operations

Format SDO_GEOM.SDO_INTERSECTION(geometry1, geometry2, tolerance[, units])Parameters geometry1: geometry object geometry2: geometry object tolerance: units: Unit of measureReturns Distance between geometries based on the closest points of the two objects

SELECT SDO_GEOM.SDO_DISTANCE(a.geometry,b.geometry,0.005,'UNIT=MILE') as Distance FROM city_limits2003_ahtd a, city_limits2003_ahtd b WHERE a.city_name = 'Prairie Grove' and b.city_name = 'Farmington'

DISTANCE----------3.35874221

SELECT b.name, SDO_GEOM.SDO_DISTANCE(a.geometry,b.geometry,0.005,'UNIT=MILE') as Distance FROM city_limits2003_ahtd a, cemeteries_gnis b WHERE a.city_name = 'Prairie Grove' and SDO_GEOM.SDO_DISTANCE(b.geometry,a.geometry,0.005,'UNIT=MILE') < 3.0

NAME DISTANCE------------------------------ --------Illinois Chapel Cemetery 1.27144539Rutherford Cemetery 2.56814328Sharp Cemetery 1.9561893

What is the minimum distance between the city limits of Farmington and Prairie Grove?

What are the cemeteries that are within 3 miles of the city limits of Prairie Grove?