Make Better Maps for Your Apps with Spatial Vector Tiles and H3 in Oracle Database 23ai

May 14, 2024 | 7 minute read
Denise Myrick
Senior Product Manager
Jean Ihm
Product Manager, Oracle Spatial and Graph
Text Size 100%:

Oracle Spatial is introducing these new features for developers in Oracle Database 23ai:Quote from Gerald Dildine, President, Integrated Transportation Information Solutions (ITIS) Corporation

  • Vector tile support: Do you want to create maps from spatial data in your Oracle database?  You can now generate vector tiles via an in-database function and then stream your spatial data as vector tiles for scalable, flexible maps for web and mobile applications. 
  • H3 support: You can use easy-to-view hexagon cells to create compelling visuals and summaries of very large volumes of point data. 

As you’ve probably heard, Oracle just announced the general availability of Oracle Database 23ai. In alignment with the focus of the release on AI and developer productivity, Oracle Spatial offers several improvements to simplify the experience of developing applications by removing the complexity associated with your database interaction. These improvements range from streamlined SQL syntax that makes it easier to work with the spatial vector data type, to a REST API for raster data and more functions for working with Lidar point clouds. You can read about these Oracle Spatial features in Oracle Database 23ai here.

Now, back to vector tiles and H3.  These are very exciting new features, as ITIS, a solutions provider for the transportation and safety sector, told us - see the quote above.

Let's learn more about them. Also, check out this video. 

What are spatial vector tiles?

In the world of maps and spatial, the vector tile format is a highly efficient, compressed data format optimized for web applications to consume and render spatial data (note: spatial vector tiles are different from AI vectors for generative AI, a powerful Oracle Database 23ai capability you may have heard of). Like GeoJSON, vector tiles enjoy wide support from developer web kits and spatial applications. But what distinguishes vector tiles is their superior performance: they allow you to get much larger volumes of data very quickly into mapping applications.

Vector tiles are also versatile, supporting dynamic styling. That is, map styles (which define the look of elements in your map) can be applied on the fly in the client, so you have flexibility in applying different styles to the same data. In addition, vector tiles provide fast performance, smooth map interactions, and dynamic map queries. They’re the industry’s preferred method for scalable delivery of spatial data to mapping client applications.

A thematic map generated from vector tiles
A thematic map generated from vector tiles

 

How do you create vector tiles in the database?

So, what we’ve done in Oracle Database 23ai to support vector tiles is to add a function that lets you generate vector tiles – just with a simple SQL call. It’s a straightforward function called sdo_util.get_vectortile().

The get_vectortile() function accepts the geometry column in a table, tile identifier, and attributes as parameters, and returns the corresponding vector tiles.

Here is an example where we’re creating a vector tile based on the geometry column in the CUSTOMERS table. Customer attribute information will also be returned to the vector tile, so that further filtering or analysis can be performed in the browser client.

SELECT sdo_util.get_vectortile(
  'CUSTOMERS',                                                                                -- table name
  'GEOM',                                                                                            -- geometry column name
  6,                                                                                                      -- tile x
  14,                                                                                                    -- tile y
  25,                                                                                                    -- tile zoom
sdo_string_array('NAME', 'ZIP', 'CITY', 'STATE', 'SALES_2022') -- attributes
FROM customers

 

You can also use an SQL query to specify criteria for data you want in your vector tile map. For example, you may want to map all the sales territories in a specific region with more than 1000 customers between the ages of 25-40.

The function returns the vector tile data as a binary structure. It is not human-readable, but it is a highly efficient, compressed format containing map data that is tailored to be consumed by web clients. And because spatial data in the database is converted to vector tiles right in the database your architecture is simplified.

To be useful to end users, the result of the vector tile query needs to get streamed out to a web application that can consume it. A great way to do this is through REST APIs, which are a convenient way for backend systems to talk to web applications. Thanks to Oracle Database as a converged database, it’s very easy to create REST APIs in the database with Oracle REST Data Services (ORDS) which takes any SQL query and exposes it as a REST API. The end result is that modern web mapping clients can consume vector tile data generated through the get_vectortile() function and exposed with REST APIs.

Now, let’s look at H3, a spatial data structure that’s great at visualizing and making sense of very large point data sets.

What is H3?

Hexagons are a very visually appealing and useful way to view data on maps, especially when you have very large amounts of dense point data, and want to easily view summaries, patterns, and clusters in data. They also have advantages in terms of geospatial analysis, coverage, and accuracy.

Oracle Spatial now provides support for hexagonal hierarchical spatial indexing (H3) in Oracle Database 23ai. H3 is an open source indexing system developed by Uber that uses hexagons in a grid system to cover the earth’s surface. With H3, data points are bucketed in hexagon cells and attributes can be aggregated and summarized over these hexagons. For very large volumes of point data, H3 cells are very useful for visualizing aggregated attribute data in thematic maps.

From the technical point of view, H3 takes dense, large-volume point data and constructs summaries of the data in a hierarchical structure. For example, you might have a data set with all the car crashes that occurred in California in 2023 with more than 100,000 data points. Visualizing these thousands of points on a map as is will make the visual representation of the data very difficult. Instead, you can use H3 to generate a data structure that summarizes the total number of crashes in each hexagon cell at different zoom levels. You can then view these on a map as color-coded hexagons – instead of as a confusing smudge of too many points. This makes it much easier to view and interpret large datasets – enabling an at -a-glance view of hot spots, clusters, and areas of low activity.

Visualization of H3 hexagons color coded by the number of EPA facilities in each hexagon
Visualization of H3 hexagons color coded by the number of incidents in each hexagon

How does H3 indexing work in Oracle Database?

In order to deliver map visualizations to your client application, you will go through two main steps – generating the H3 index and then turning the H3 into vector tiles.

First, you generate the H3 index for the point data we’re interested in using the H3 hierarchical grid system. H3 index creation is done with the new function SDO_UTIL.H3SUM_CREATETABLE(), which creates a new table in the database for the H3 representation of the data. You specify your input data (such as crash locations) and pick the type of aggregation you want (such as the count of crashes in each cell).

Second, you turn H3  hexagons into vector tiles using the new function SDO_UTIL.H3SUM_VECTORTILE(). This is similar to what we described with the get_vectortiles( ) function above, except that this function is specifically for converting H3 hexagons into vector tiles. With these 2 simple steps, you can aggregate a large data set into an aggregated hexagon data set and visualize it as thematic maps that are easy to interpret and visually appealing. Your web applications can easily consume the hexagon data as vector tiles exposed with a REST API.

Summary

Vector tiles and H3 are very popular techniques for maps in web and mobile applications, so we made vector tiles and H3 developer-ready in Oracle Database 23ai – you can work with them right out of the database. These new features will help you create powerful maps from your data and enhance your web applications, for data-driven applications with integrated spatial analytics.

Learn More

The documentation can be found here.  
Look for future AskTOM sessions about these and other new features, or join us on LinkedIn to get all the latest updates.

Denise Myrick

Senior Product Manager

Denise Myrick is a Senior Product Manager with the Spatial and Graph Product Management team. She is based in Nashua, New Hampshire.

Jean Ihm

Product Manager, Oracle Spatial and Graph

Jean Ihm is a product manager for Oracle's spatial and graph technologies for database, big data, and cloud platforms.  She works on product release activities, interacts with customers and partners worldwide, engages with presales, and helps organize user events.  She is based at Oracle headquarters in Redwood Shores, CA, and collaborates closely with the spatial and graph development team in Nashua, NH.


Previous Post

Oracle Globally Distributed Database addresses multi-country data residency challenges for Munich Re HealthTech

Deeksha Sehgal | 8 min read