Topology In Oracle Spatial

 What is Topology in Oracle Spatial?

I suggest you watch the video below about this article.



Imagine you have a map with streets, parks, and buildings. Topology is like a rulebook that defines relationships between these things:

  • Points (like a park's location)
  • Lines (like roads or rivers)
  • Areas (like a city block or a lake)

With topology, we can say:

  • Roads connect at intersections.
  • A park can't overlap a building.
  • A lake must stay inside its boundary.

Using topology helps keep your data correct and makes spatial queries faster. For example:

  • Find all parks next to a river.
  • Check if two roads cross.
  • Ensure no two buildings overlap.

How to Implement Topology in Oracle Spatial?

1) Create a Topology

A topology is like a container for your spatial data.

BEGIN SDO_TOPO.CREATE_TOPOLOGY( 'CITY_TOPO', -- Name of the topology 'USER_SCHEMA', -- Your database schema 0.005, -- Tolerance for geometric operations 'GEOMETRY_TABLE'); -- Table to hold the spatial data END;

2) Create Spatial Tables

You'll create tables for points, lines, and polygons.

-- Points (like intersections) CREATE TABLE POINTS ( ID NUMBER PRIMARY KEY, GEOM SDO_GEOMETRY ); -- Lines (like streets) CREATE TABLE LINES ( ID NUMBER PRIMARY KEY, GEOM SDO_GEOMETRY ); -- Polygons (like city blocks) CREATE TABLE POLYGONS ( ID NUMBER PRIMARY KEY, GEOM SDO_GEOMETRY );

3) Add Data

Insert some data into your tables.

INSERT INTO POINTS VALUES ( 1, SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(10, 10, NULL), NULL, NULL) ); INSERT INTO LINES VALUES ( 1, SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(10, 10, 20, 20)) ); INSERT INTO POLYGONS VALUES ( 1, SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(5, 5, 15, 5, 15, 15, 5, 15, 5, 5)) );

4) Build Topology

Load this data into your topology.

BEGIN SDO_TOPO.LOAD_TOPOLOGY_LAYER( 'CITY_TOPO', 'POINTS', 'LINES', 'POLYGONS' ); END;

5) Perform Topology Queries

You can now query relationships, like finding which points are inside polygons.

SELECT p.ID FROM POINTS p, POLYGONS g WHERE SDO_INSIDE(p.GEOM, g.GEOM) = 'TRUE';



Comments

Popular posts from this blog

JavaScript In Oracle APEX (Client Side)

Installation of Oracle Database 23ai and APEX 24.2 and ORDS 24.4 on Windows Step-by-Step

Building a Fully Local AI-Powered Assistant with Oracle APEX and Vector Search #APEXCONN2025 #orclAPEX

Configuration of ORDS: Standalone, Tomcat, and WebLogic on Windows Step-by-Step

✔ RTL Map Region Labels APEX 24.2 & 🌍GeoCoding

Building an AI-Powered Resume Matching System Using Oracle APEX and 23ai Vector Search😎

Oracle JET and Oracle APEX are best friends💕

Vector Tiles in Oracle Spatial 23

What is SYS.ODCI (SYS.ODCINumberList or SYS.ODCIVarchar2List) and How Can Use it in APEX ?

My Experience at Oracle CloudWorld Tour in Frankfurt – April 10, 2025