Before you start
Learn what to expect from this tutorial, and how to get the most out of it.
For over 10 years, the DB2 Spatial Extender has provided the capability of managing and analyzing spatial data stored in DB2 relational tables. Table columns can be defined with spatial types for points, lines, and polygons, which can represent objects such as the following:
- Point locations
- Customers, retail stores, electrical transformers, cell towers
- Highways, coastline, delivery routes, electrical transmission lines
- Sales/service territories, flood/fire risk, states/provinces/counties
SQL queries can incorporate spatial functions to analyze spatial relationships, such as finding customers within a floodzone. Listing 1 shows an example of code that incorporates spatial functions.
Listing 1. Query that incorporates spatial functions
SELECT cust_name, cust_addr FROM customers, floodzones WHERE ST_Within(cust_loc, flood_loc) = 1
The result of this query produces a set of customer names and addresses whose houses could be at risk of flooding. This information is useful in calculating insurance rates or sending out an offer to purchase flood insurance.
This series of tutorials takes you through common tasks when working with spatial data in the DB2 Spatial Extender. This includes importing and creating spatial data, constructing and executing spatial queries, working with IBM, third party, and open source spatial tools, tuning performance, and considering special circumstances in a data warehouse environment.
Although the focus of this tutorial series is DB2 Spatial Extender on the Linux®, UNIX®, and Windows® operating systems, many of the concepts are equally applicable to other IBM database offerings with spatial capability, including the following:
- Spatial Support for DB2 for z/OS®
- Informix® Spatial Datablade
- Netezza® Spatial
The following additional tutorials are planned for this 5-part series.
- Part 2: Implementing typical spatial use cases
There are a number of typical use cases in spatial application that include spatial joins,
distance queries, geofencing, and nearest-n queries.
This tutorial provides examples for implementing these use cases efficiently.
- Part 3: Spatial application tuning
- Application performance is always an important consideration.
This tutorial looks at factors in spatial application performance and tools for understanding
Some of the factors considered include inline data, data clustering, compression, and generalization.
- Part 4: Spatial analysis in a data warehouse environment
Achieving good scalability in an InfoSphere Warehouse shared-nothing environment requires
This tutorial addresses the techniques to get good spatial query co-location.
It also provides special considerations when working with Esri middleware.
- Part 5: Spatial visualization tools from IBM, third parties, and open sources
- Visualization of spatial data is often an important aspect of a spatial application. This tutorial introduces some of the tools that are available, including the free IBM Geobrowser, Esri software, web-mapping services, such as Google maps, and open-source software that uses the GeoTools driver for DB2.
This tutorial introduces you to the technology provided by DB2 Spatial Extender. The tutorial also offers approaches to populating DB2 tables with spatial data: a critical step before spatial queries can be implemented. This tutorial also addresses environments for executing spatial queries, including the DB2 command line processor, IBM Data Studio, and embedded in an application using JDBC, CLI, and other interfaces.
When you have finished this tutorial, you will:
- Understand important spatial concepts relating to spatial types and coordinate systems
- Know approaches to importing and creating spatial data
- Understand spatial indexing
- Be familiar with environments for executing spatial queries
This tutorial targets application architects and developers who have a working knowledge of DB2 and the SQL language.
Download the sample SQL scripts, Java application, and sample data from the Downloads section to a convenient directory in order to follow the examples in this tutorial.
In order to work through the steps of the tutorial, you need a working DB2 environment with Spatial Extender installed and configured. See Resources for information about setting up this environment.