Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

33
GeoInfo2003 Interface for spatial operations in geographical database Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto Câmara

Transcript of Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

Page 1: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo2003

Interface for spatial operations in geographical database

Karine Reis Ferreira

João Argemiro Carvalho Paiva

Gilberto Câmara

Page 2: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Summary

• Introduction – New generation of GIS and spatial DBMS

– Challenges

– TerraLib

• Goal

• API for spatial operations

– Vector and raster data

• Conclusion and future works

Page 3: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

New generation of GIS

• DBMS (Database Management System) to manage spatial data [Rigaux et al, 2002]– Object-relational DBMS and spatial extension

• Transition from the monolithic systems to Spatial Information Appliances [Egenhofer, 1999] – Small GIS tailored to specific user needs

• Modular and extensible [Voisard and Schweppe,1997] – Support for addition of independent autonomous

systems

Page 4: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

GIS and DBMS

• Use of DBMS to store, manipulate and manage spatial data (descriptive and geometrical data)

– Relational DBMS

� Scheme

� Binary long type (BLOB)

– Object-relational DBMS

� Spatial data types defined by spatial extensions

attributes

GGISIS

DBMS

Page 5: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Spatial Extension

• Extends object-relational DBMS for treat spatial data:

– Data Model: spatial data types (SDTs)

– Query language: operations and query on SDTs

– Spatial indexing methods (ex. R-Tree) and spatial join

• DBMS + spatial extension = Spatial DBMS

• Oracle Spatial, IBM DB2 Spatial Extender, Informix Spatial Datablade, PostGIS (PostgreSQL) and Spatial Extension in MySQL (release 4.1)

Page 6: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Spatial Extension

• Oracle Spatial

CREATE TABLE STATES (state_id NUMBER,name VARCHAR2(100)geometry MDSYS.SDO_GEOMETRY);

SELECT ES.state_idFROM STATES ES, RIVERS RIWHERE RI.gid = 234 AND

SDO_RELATE(ES.geometry, RI.geometry, ‘mask=CONTAINSquerytype=WINDOW’)= ’TRUE’;

• Oracle Spatial:

– Spatial data type: SDO_GEOMETRY

– Operators and functions

� SDO_RELATE, SDO_BUFFER, SDO_AREA

– Spatial indexing: R-Tree e QuadTree

Page 7: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Challenges

• Develop small GIS that:

– supports different DBMS, relational and object-relational

– treats the differences between spatial DBMS

– extends necessary spatial data types for geographical applications, ex. raster data

– provides spatial operations on spatial data types stored in different DBMS

Page 8: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

TerraLib

• Open source GIS software library

• Provides support for the development of:

– Small GIS

� DBMS for manage spatial data

• Support for different DBMS

– Oracle, Oracle Spatial, MySQL, SQL Server, PostgreSQL

Page 9: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

TerraLib

Access

TerraLib

MySQL Driver PostgreSQL Driver

TeDatabase

MySQL Oracle Spatial

PostgreSQL

ADO Driver OracleSpatial Driver

SQLServer

• Interface with DBMS

Page 10: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

TerraLib

• TerraLib data model

TeDatabase

OracleSpatial DriverMySQL Driver

OracleSpatial

MySQL

createPolygonTable(tableName)

Page 11: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Goal

Development of a generic programming interface or API (Application Programming Interface) for spatial operations in geographical database in the TerraLibenvironment.

Page 12: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Challenges

• Develop small GIS that:

– supports different DBMS, relational and object-relational

– treats the differences between spatial DBMS

– extends necessary spatial data types for geographical applications, ex. raster data

– provides spatial operations on spatial data types stored in different DBMS

Page 13: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API for spatial operations

• Function set for spatial operations on geographical data stored in DBMS

• Generic API: supports relational and object-relational DBMS

• Explores spatial extension functionalities

TerraLib

API forSpatial

Operations

Oracle SpatialAccess

MySQLPostgre

SQL

DBMS

Geographic Application

Spatial Operations

Spatial Operations

Page 14: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API for spatial operations

Intersection

Union

Difference/XOr

calculateDistanceSpatialRelation

NearestNeighbors

Binary

(VD + VD)

MaskZonal-Binary

(VD + RD)

Buffer

ConvexHull

Centroid

calculateLength

calculateArea-

Unary

(VD)

SpatialScalarBoolean

VD: Vector Data RD: Raster Dada

• Vector and raster data

Page 15: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

DBMS

SELECT *

FROM geomTable

WHERE sigla= “MG”

calculateArea (“MG”)

blob

double Area (TePolygon poly)

TerraLib

(1)

(2)TePolygon

area

• DBMS without spatial extension – TeDatabase

(1) Get geometries from database

(2) Use TerraLib functions to compute operations

Page 16: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

DBMSOracle Spatial

SELECT SDO_GEOM.SDO_AREA(

geomTable, spatial_data, ...)

FROM geomTable WHERE sigla= “MG”

calculateArea (“MG”)

TerraLib

area

• DBMS with spatial extension

– Oracle Spatial Driver

� Use operators and functions of the spatial extension with SQL language

� Operations are computed by spatial DBMS

Page 17: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• SpatialRelation Operation

– Returns the geographical objects which present a specific topological relation

– Topological relation [Egenhofer et al, 1994]

� TeDisjoint

� TeTouches

� TeCrosses

� TeWithin

� TeOverlap

� TeContains

� TeIntersects

� TeEquals

� TeCovers

� TeCoveredBy

Page 18: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• SpatialRelation Operation

– DBMS without spatial extension

(1) Gets geometries from database based in their minimal boundary rectangle (MBR)

(2) Uses TerraLib topological functions

Page 19: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• SpatialRelation Operation

– DBMS without spatial extension

(1) Gets geometries from database based in their minimal boundary rectangle (MBR)

(2) Uses TerraLib topological functions

Page 20: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• SpatialRelation Operation

– Oracle Spatial Driver

� Builds a SQL query using the SDO_RELATE operator

� Operation computed by spatial extension

SELECT geomTable1.*

FROM state_polygons geomTable1,

state_polygons geomTable2

WHERE geomTable2.object_id = 'MG'

AND SDO_RELATE(geomTable1.spatial_data,

geomTable2.spatial_data,

'mask = TOUCH querytype=WINDOW')='TRUE'

Page 21: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• Buffer Operation

– Generates a new geometry based on a distance to a specific geographical object

– Oracle Spatial Driver

Oracle Spatial

SELECT SDO_GEOM.SDO_BUFFER(g.spatial_data, m.diminfo, 1.0)

FROM test_Line g, USER_SDO_GEOM_METADATA m

WHERE m.table_name = 'test_Line'

AND m.column_name = 'spatial_data'

AND object_id = '17'

Page 22: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• Buffer Operation

– Generates a new geometry based on a distance to a specific geographical object

– Oracle Spatial Driver

Oracle Spatial

SDO_GEOMETRY (2003, NULL, NULL,

SDO_ELEM_INFO_ARRAY (1, 1005, 8, 1, 2, 2, 5, 2, 1, ..., 9, 2, 2),

SDO_ORDINATE_ARRAY (18, 17, 19, 18, 18, 19, 16.4142136, 19,

14.7071068, 20.7071068, 14, 21, ..., 20.7071068)

Page 23: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• Buffer Operation

– SDO_GEOMETRY

� Compound polygon: straight line segments (2 points) and circular arcs (3 points).

– TePolygon

� straight line segments (2 points)

Page 24: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Vector data

• Buffer Operation

– Generates a TePolygon from a SDO_GEOMETRY

� TeGenerateArc function

� Generates an arc through 3 points

pt1

spt3 pt2

C(x0, y0)

r� ?�

ptnpt1

spt3 pt2

C(x0, y0)

r� ?�

ptn

Page 25: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Zonal Operation

• Calculates statistics of a region or zone of a raster data

Page 26: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Zonal Operation

• Calculates statistics of a region or zone of a raster data

Page 27: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Mask Operation

– Clips a raster data using a mask

Page 28: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Mask Operation

– Clips a raster data using a mask

Page 29: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Mask Operation

– Clips a raster data using a mask

Page 30: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Mechanism to traverse a raster data only in a region inside or outside a specific polygon

• Developed:

– Iterator concept on TeRaster structure

� IteratorPoly

– Route strategies

Page 31: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

API – Raster Data

• Iterator is an abstraction of a pointer to a sequence [Stroustrup, 1999]

• Generic programming: disconnect data structures fromalgorithms

TeCalculateStatistics(itBegin, itEnd, stat)

TeRaster::iteratorPoly itBegin = raster->begin(poly, TeBoxPiIn)

TeRaster::iteratorPoly itEnd = raster->end(poly, TeBoxPixelIn)

TeRaster* rasterData Structure

Iterator

Algorithm

Page 32: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

Conclusions

• Spatial operations are essential in a geographical application

• The developed API:– Provides spatial operations on a high level of

abstraction for the developers of geographical application

– Explores a new generation of object-relational DBMS that manage geographical data

Page 33: Karine Reis Ferreira João Argemiro Carvalho Paiva Gilberto ...

GeoInfo 2003

• Implement other operations on raster data:

– Mathematical Operations

– Reclassify

– Slice

– Weight

• Extend the API to support new spatial extensions

– Spatial Extension in MySQL (release 4.1)

• Use future resources of spatial extensions to treat raster data (ex. Oracle Spacial)

Future Works