Tutorial 3: Using your own geospatial data
This is the last of a series of three tutorials that show you how to analyze geospatial data with Db2® and Esri ArcGIS:
- If you want to learn how to work with base maps first, view the first tutorial of this series: Tutorial 1: Working with base maps.
- Do you want to learn how to create your own maps? Then, view the second tutorial of this series: Tutorial 2: Creating new maps.
This tutorial shows you how to carry out the following tasks:
- Load your own geospatial data into Db2.
- Use uploaded data.
Time required
10 minutesScenario
Difficulty
Beginner
Audience
Data scientists
System requirements
- Windows 7 Ultimate, Professional and Enterprise (32 bit and 64 bit [EM64T])
- Windows 8 Pro and Enterprise (32 bit and 64 bit [EM64T])
- Windows 8.1 Pro and Enterprise (32 bit and 64 bit [EM64T])
Prerequisites
This scenario uses an Esri ArcGIS for Desktop installation that is connected to Db2 to visualize and analyze geospatial data (see Connecting Esri ArcGIS for Desktop). The data for this scenario is already loaded into your Db2 database. This scenario assumes that you already know how to work with base maps and how to create your own maps.
Preparing data for an individual geospatial load
Now, we'll show you how to load new geospatial data into your Db2 database, and how to put that data to use. But first, some background information: Geospatial data is typically made available in the form of shapefile sets. Many organizations such as the US Census Bureau and the US National Weather Service provide shapefile sets that can be downloaded from the internet.
For example, the US National Weather Service provides shapefile sets that contain data about current weather warnings. An insurance company could use this data to determine which customers are in danger and to warn them. This would give the customers time to secure their property and to prevent damage, which would benefit both the customers and the insurance company. You can download the files that contain geospatial data about current weather warnings from the National Weather Service Data Download in GIS Format page of the US National Weather Service website.
Procedure
Loading geospatial data into Db2
Procedure
- The Db2 web console provides a wizard that you can use to load shapefiles into your Db2 database. To access this page, go back to the Db2 welcome page and open the menu there. Click Load, then Load Geospatial Data.
- This opens the first page of the wizard for loading geospatial data. The source file must be a compressed .zip, .gz, or .tar file. Hover your pointer over the question mark icon to display the other requirements of the source file. For example, each file in the shapefile set must have the same base name and must be in the root directory of the compressed file.
- Click Browse files, select the compressed file that contains the geospatial data to be loaded, and click Open.
- When the name of the file is displayed in the File Name field, click Next.
- Db2 uploads the data and displays a check mark when the process has finished. Then, click Next.
- On this page, specify the name of the table that is to contain the uploaded geospatial data. In this scenario, we'll name the table GEO_WEATHER_WARNINGS.
- Db2 displays the spatial reference systems that your uploaded table can use. If no spatial reference system matches your data, you can create a new one as needed. In this scenario, select the WGS84_SRS_1003 entry and click Next.
- After you click Finish, you are informed that the load was successful and how many rows the table contains. If you scroll down, you can see a preview of the table.
- If you want even more information, you can click View full table structure and details. The Tables page opens.
- Select the schema and then select the new table that you just created for your geospatial data. When you select the table, Db2 displays a list of its columns.
- To view the data contained in the table, click the Browse Data tab. When you're finished reviewing the data, return to ArcMap.
Using uploaded data
Procedure
SELECT W.*, (
SELECT SUM(C.INSURANCE_VALUE)
FROM SAMPLES.GEO_CUSTOMER AS C
WHERE DB2GSE.ST_INTERSECTS(W.GEO_DATA,C.SHAPE) = 1 SELECTIVITY 0.00001
) AS COUNTY_INSURANCE_VALUE
FROM GEO_WEATHER_WARNINGS AS W
SELECT * FROM SAMPLES.GEO_CUSTOMER WHERE OBJECTID IN (
SELECT DISTINCT C.OBJECTID
FROM SAMPLES.GEO_CUSTOMER AS C,
GEO_WEATHER_WARNINGS AS W
WHERE DB2GSE.ST_INTERSECTS(W.GEO_DATA,C.SHAPE) = 1 SELECTIVITY 0.00001
)