Before you start
For many years, DB2, Informix and Netezza have provided the capability of managing and analyzing spatial data in relational tables. Table columns can be defined with spatial types for points, lines, and polygons, which can represent objects like:
- Point locations — Customers, retail stores, electrical transformers, cell towers
- Lines — Highways, coastline, delivery routes, electrical transmission lines
- Polygons — 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 flood zone. For example:
SELECT cust_name, cust_addr FROM customers, flood zones WHERE ST_Within(cust_loc, flood_loc) = 1
The result of this query would produce a set of customer names and addresses whose houses could be at risk of flooding. This might be useful in calculating insurance rates or sending out an offer to purchase flood insurance.
In many cases, additional insight can be derived by visualizing the result in a mapping tool. As they say, "A picture is worth a thousand words." The rest of this tutorial will show you how to use the free geobrowser to visualize this data from DB2 tables.
Figure 1. Kentucky customers highlighting in red those in a flood zone
This tutorial takes you through setting up DB2 with a sample database, setting up the geobrowser, and running the geobrowser to visualize spatial tables and the results of spatial analysis. Suggestions are provided to efficiently work with spatial data and explore additional spatial visualization techniques.
Although this tutorial is based on DB2 for Linux®, UNIX®, and Windows®, the same operations are possible, with minor changes, using DB2 for z/OS®, Informix or Netezza.
This tutorial is written for spatial application developers and database application developers. You should have some familiarity with spatial data and working with SQL queries.
To run the examples, you need a Windows or Linux environment with about 500 MB available to install DB2 and the geobrowser. If DB2 is already installed, you only need about 20 MB.