Page 1
Software Group – Spatial Information Management
© 2004 IBM Corporation
Putting the world in your Database:The Informix Spatial and Geodetic DataBlades
Robert UlemanConsulting IT SpecialistWorldwide Information Management Sales Support – Spatiotemporal Technology
Page 2
Software Group – Spatial Information Management
© 2003 IBM Corporation2
Agenda
Overview– GIS: Geographic Information Systems– Spatial data in an object-relational DBMS– The Spatial DataBlade– Competitive differences
Details– Spatial SQL syntax– Spatial indexing– Geodetic: round-earth spatial
Page 3
Software Group – Spatial Information Management
© 2003 IBM Corporation3
Geographic Information System
Page 4
Software Group – Spatial Information Management
© 2003 IBM Corporation4
Page 5
Software Group – Spatial Information Management
© 2003 IBM Corporation5
GIS Application
GIS Application
SQL
Proprietarydata format1st Generation:
2nd Generation:
3rd Generation:SQL
ProprietaryGIS API
ProprietaryGIS APIGIS
Application
GIS Application
GIS Application
GIS Application
FileSyste
m
FileSyste
m
GIS Data
Engin
e
GIS Data
Engin
eRDBMSRDBMS
“Spatial” Application
“Spatial” Application
Architectural Evolution of GIS Data Management
Spatially enabled DBMS
Spatially enabled DBMS
RDBMSRDBMSSQL
Spatial features, indexes in
BLOBs
Attributes
GIS Data
Engin
e
GIS Data
Engin
e
Spatial types functions indexes
Spatial Features
Proprietaryspatial
structures
Open or proprietary
Open
Spatial business logicSpatial business logic
Page 6
Software Group – Spatial Information Management
© 2003 IBM Corporation6
What’s Special about Spatial?
Traditionally not supported by relational databases Requires new indexing techniques Voluminous data
– Individual values can get arbitrarily large:• Large, convoluted lines and polygons (e.g., a coastline)• Raster images
– Lots of features Maps can effectively represent lots of information
– Much more than spreadsheets or reports– Queries often retrieve many more rows than “normal”
queries Individual operations may be computationally expensive
– WHERE clause predicates Transactions generally long, unlike OLTP
– Resembles code revision control in software development
Page 7
Software Group – Spatial Information Management
© 2003 IBM Corporation7
Extender/DataBlade Introduction: Component Technology
ConnectivityConnectivity BackupBackup RestoreRestoreServer SubsystemsServer Subsystems
IDSIDSIDSIDSSpatialGeodetic
GridYour idea goes here
SpatialGeodetic
GridYour idea goes here
Page 8
Software Group – Spatial Information Management
© 2003 IBM Corporation8
Extender/DataBlade Elements
TypesTypes
FunctionsFunctions
CastsCasts
AggregatesAggregates
IndexesIndexes
TablesTables
Client CodeClient Code
New New Extender/Extender/DataBladeDataBlade
New New Extender/Extender/DataBladeDataBlade
Page 9
Software Group – Spatial Information Management
© 2003 IBM Corporation9
If Integer were not built in …
Domain– Whole numbers, up to some maximum magnitude
Data types– Smallint, Integer, Bigint– Representations: ASCII ([+|-]d..),
binary (2’s complement, byte order)Functions and operators
– Add(+), Subtract(-), Multiply(*), Abs, Mod, …– Equal(=), LessThan(<), GreaterThanOrEqual(>=), …
Index support– B-Tree
Page 10
Software Group – Spatial Information Management
© 2003 IBM Corporation10
Integer not built in? Not so far-fetched
Illustra: Pure object-relational database– Commercialization of UC Berkeley Postgres project– Acquired by Informix in 1996, Informix acquired by IBM in 2001– Postgres continues as open-source PostgreSQL– No built-in data types; everything is bound at runtime
Land Information New Zealand: Fraction data type “5/7”– Avoid roundoff in cumulative subdivision of property– Legally mandated improvement in area/tax calculation precision
Dates– Birthdate: understands that February 28 is a birthday for
someone born on February 29– Tradingdate: skips weekends, holidays
Page 11
Software Group – Spatial Information Management
© 2003 IBM Corporation11
User-Defined Data Types
compensation locationname jobs_held
CREATE TABLE employee (name varchar(30),compensation salary_t,location point,jobs_held set(varchar(30)),picture image
);
John T. Smith (123 256) Clerk, Administrator, Manager
image
349,876 yen
Data Type: Descriptor assigned to a column or a variable
Page 12
Software Group – Spatial Information Management
© 2003 IBM Corporation12
Some SQL Queries Location-Based Services: List Points of Interest
– SELECT name, description, addressFROM restaurantsWHERE Overlaps(location, box(getGPS(), 2000, 2000))AND category = ‘chinese’AND docContains(menu, ‘Peking duck’);
List volcanic eruptions in a region of interest– SELECT name, year, mag, locationFROM volcanoWHERE ST_Within(location,'polygon((-125 43,-125 46,-120 46,-120 43,-125 43))')ORDER BY name, year;
name year mag location HOOD MOUNT 1854 0 POINT (-121.69999 45.36000) HOOD MOUNT 1859 2 POINT (-121.69999 45.36000)
Name Description AddressDynastie Chinese restaurant in
glass pyramidMisburger Str. 81
Page 13
Software Group – Spatial Information Management
© 2003 IBM Corporation13
OpenGIS Standard Spatial Types and Functions– Certified compliant with OpenGIS Simple Features Specification
– Geometric data types
• ST_Point, ST_Linestring, ST_Polygon, ST_Geometry, etc.
– Spatial functions
• ST_Distance, ST_Intersects, ST_Within, etc.
– Standard Data representations
• Well-Known Binary, Well-Known Text, ESRI Shape Tailored to ESRI’s ArcSDE 9.x (spatial database gateway)
– Additional functions, support for annotation, SDE format, etc.
– Based on ESRI’s geometry engine (Shape library)
– Consistent results of spatial operations in all software tiers: database, middle (ArcSDE), client (ArcGIS, ArcIMS)
The Informix Spatial DataBlade
Page 14
Software Group – Spatial Information Management
© 2003 IBM Corporation14
DB2 Spatial Extender, IDS Spatial DataBlade
Developed, supported and maintained by IBM
– Wrapped around ESRI’s geometry engine (Shape library)
– Spatial index: R-tree
– Spatially aware optimizer
• Recognizes spatial operators and index
• Cost, selectivity provided by R-tree
– Administration tools: Blade Manager
– Utilities: Shape file import, export
Strategic alliance with ESRI
– Close relationship in engineering, marketing, and sales
– Software (Data, WebSphere), Hardware, Services
Page 15
Software Group – Spatial Information Management
© 2003 IBM Corporation15
Spatial/OpenGIS SQL Data Types
ST_Geometry
ST_Curve ST_SurfaceST_Geom-Collection
ST_Multi-Surface
ST_Multi-Curve
ST_LineString ST_Polygon
ST_Point
ST_Multi-Polygon
ST_Multi-LineString
ST_Multi-Point
“Abstract” Classes
Instantiable Classes
Page 16
Software Group – Spatial Information Management
© 2003 IBM Corporation16
OpenGIS Spatial SQL Functions
ST_Intersects(geometry1,geometry2)
?
Page 17
Software Group – Spatial Information Management
© 2003 IBM Corporation17
ClientClient
SDE SDE Client APIClient API
ArcGIS Family
Open API
ApplicationApplication
ArcSDEArcSDEServerServer
IDS
SQL SQL ApplicationsApplications
Spatial DataBlade
ArcSDE Architecture for Informix
R-tree index
ODBCODBC
OpenGISSpatialQueries
CachingCompression Connection pooling(Projections)(Long transactions)(Raster support)
ESQL/CODBCJDBC
TCP/IPTCP/IP
Geodatabase, business rules, custom types
ArcExplorerArcExplorer
JDBC
Page 18
Software Group – Spatial Information Management
© 2003 IBM Corporation18
FATArcSDEServer
<nothing>
ArcSDE Architecture for Others
SQL Applications
ArcSDEServer
Oracle
Oracle Spatial
Index tables
SQL Applications
NO SpatialQueries
OracleSpatialQueries
ArcSDEServer
Informix
Spatial DataBlade
SQL Applications
OpenGISSpatialQueries
SQLServer,Oracle “binary”
Page 19
Software Group – Spatial Information Management
© 2003 IBM Corporation19
The Informix Spatial Advantage Standard, intuitive syntax
– Easy development, maintainable, fewer bugs
– Result of true Object-Relational extensibility
– OpenGIS Simple Features conformance for interoperability with other compliant systems
Performance
– Spatial index and functions integrated into server at code interface level, not based on tables and SQL
Tight cooperation and integration with ESRI
Page 20
Software Group – Spatial Information Management
© 2003 IBM Corporation21
SQL Comparisons: Query
Oracle SpatialSELECT A.Feature_IDFROM TARGET AWHERE
sdo_relate( A.shape, mdsys.sdo_geometry( 2003, NULL, NULL, mdsys.sdo_elem_info_array( 1,1003,1 ), mdsys.sdo_ordinate_array( x1,y1, x2,y2, x3,y3, x4,y4, … ) ), 'mask=anyinteract querytype=window‘) = 'TRUE‘
;
DB2 SpatialSELECT A.Feature_IDFROM AWHERE
ST_Overlaps( A.shape, ST_GeomFromText( ‘ST_POLYGON( x1 y1, x2 y2, x3 y3, x4 y4 … )’, 5 -- OpenGIS requirement ))
;
Page 21
Software Group – Spatial Information Management
© 2003 IBM Corporation22
Spatial queries
Compute the percentage overlap of imagery that covers part of a region of interest
– ROI = Ontario Province, with 25 km buffer, but only over Canada
SELECT i.id AS image_id, ST_Area(ST_MultiPolygon ST_Intersection( i.footprint, p.shape ) ::ST_Polygon ) / ST_Area( i.footprint ) * 100 AS "%overlap"FROM images i, provinces pWHERE ST_Overlaps( i.footprint, ST_Difference( ST_Buffer( p.shape, 25, 'KILOMETRE' ), (SELECT shape FROM countries WHERE name = 'USA')) AND p.name = 'Ontario'ORDER BY 2 DESC;
Page 22
Software Group – Spatial Information Management
© 2003 IBM Corporation25
The B-tree index
A through Z
A - I S - Z
A - B C - E P - R Sq - U
B-tree indexes rapidly reduce the number of items to search through in a selection process and are the industry standard for alpha-numeric data. But how can spatial data be sorted???
J - R
F - I M - OJ - L S - Sp V - Z
“Polygon”
Page 23
N2
N1
K8 K9
L4
K8
K9
L5
K10
K11
N1 N2
L4 L5
K10 K11
A Simple R-treeK = Key bounding boxL = Leaf node bounding boxN = Node (internal) bounding box
L1
L2 L3
L1 L2
K1
K1
K2
K4
K3
K5
K6 K7
L3
K5 K6 K7K2 K3 K3 K4
Data space
Index structure
SearchObject
Page 24
Software Group – Spatial Information Management
© 2003 IBM Corporation27
Planar Coordinates
500,000
5,000,000
Northing
Easting
Page 25
Software Group – Spatial Information Management
© 2003 IBM Corporation28
longitude
latitude
0
-90(90° W)
+90(90° N)
R
Spherical Coordinates
Page 26
Software Group – Spatial Information Management
© 2003 IBM Corporation29
Flattening the Earth
Plane Geometry on lat-long
– Singularities and scale distortion at and toward the poles
– Wrap-aroundat 180º longitude
– Poor location of lines, edges, intersections
Local/Regional Projections
– Limited valid range
– Map edge-matching problems
– Non-uniform scale
Indexing: it gets worse!
– Multiple “bounding boxes” or complete loss of selectivity
UTM 32
UTM 33
?
?
?
?
0
0-180 +180-90
+90
Page 27
Software Group – Spatial Information Management
© 2003 IBM Corporation30
FLAT
0° ±180°±180°
Single bounding box: high
selectivity, low
complexity
+180-180 0 +90-90-90
0
+90
Y↑
→ X
Single bounding strip: low selectivity
Split bounding
boxes: high complexity
ROUND
Page 28
Software Group – Spatial Information Management
© 2003 IBM Corporation31
Geodetic DataBlade/Extender Latitude-longitude (‘geodetic’) coordinates, ellipsoidal datum
Uniform accuracy and resolution around the globe (“world to cm”)
No scale singularities and map edges
Based on Hipparchus geometry engine by Geodyssey Ltd.
Integrated time and floating-point dimensions for single-index searches and true spatio-temporal data management
Powerful indexes for high performance:
– Voronoi Tessellation – adaptive space partitioning
– R-tree – self-tuning multidimensional index (up to 5 dimensions)
Unique to IBM
Page 29
Software Group – Spatial Information Management
© 2003 IBM Corporation32
Connect the dots...
Flat plane: line segmentsconnecting vertices are
straight lines
Ellipsoid: line segmentsconnecting vertices are
geodesics
Page 30
Software Group – Spatial Information Management
© 2003 IBM Corporation33
Connect the dots, continued
parallels
meridians
Add vertices if you want a line segmentto follow a parallel (line of constant
latitude)
Page 31
Software Group – Spatial Information Management
© 2003 IBM Corporation34
Distances
What is the distance from Anchorage to Tokyo?
The shortest path is the shorter of thetwo possible geodesic paths:the thick part of the great circle
Page 32
Software Group – Spatial Information Management
© 2003 IBM Corporation35
Polygons that straddle the 180th meridiansplit flat-plane representation into 2 or more pieces
MULTIPOLYGON( ((-180 30,-165 30,-165 40, -180 40,-180 30)), ((180 30,180 40,165 40, 165 30, 180 30)))
POLYGON( (165 30, -165 30, -165 40, 165 40))
Page 33
Software Group – Spatial Information Management
© 2003 IBM Corporation36
Polygons that enclose a pole
extra vertex extra vertex extra edgeextra edge
POLYGON( (180 -60, -180 -60, -180 -90, 180 -90, -180 -60))
POLYGON( ( 0 -60, -120 -60, 120 -60, 0 -60))
Page 34
Software Group – Spatial Information Management
© 2003 IBM Corporation37
HemispheresWestern hemisphere, flat-earth representation:
POLYGON((0 -90, 0 90, -180 90, 180 -90, 0 -90))
Western hemisphere, round-earth representation:
POLYGON((0 -30, 0 90, 180 -30))
1
2
3
4 1
23
Note that the same three points, specified in opposite order, define the eastern hemisphere