## Top 5 Recent Articles

##### ARTICLES CATEGORIES

- Algorithms (22)
- All (399)
- Biography (1)
- Blog (44)
- Business Requirements (1)
- Commentary (1)
- Conversion (2)
- Customers (2)
- Data Models (1)
- Education (2)
- GeoRaptor (13)
- GPS (1)
- Image Processing (2)
- Import Export (8)
- Licensing (2)
- LiDAR (1)
- Linear Referencing (4)
- Manifold GIS (3)
- Mapping (1)
- MySQL Spatial (7)
- Networking and Routing (including Optimization) (5)
- Open Source (18)
- Oracle Spatial and Locator (194)
- Partitioning (1)
- PostGIS (36)
- Projections (1)
- Published Articles (1)
- qGIS (1)
- Recommendations (1)
- Services (1)
- Software Change Log (1)
- Source Code (37)
- Space Curves (9)
- Spatial Database Functions (109)
- Spatial DB comparison (1)
- Spatial XML Processing (11)
- SQL Server Spatial (92)
- Standards (3)
- Stored Procedure (17)
- Tessellation or Gridding (10)
- Tools (2)
- Topological Relationships (1)
- Training (2)
- Triangulation (2)

# Topological vs Non-Topological Simplification/Generalization of Aggregated Area Geometies in Oracle

Oracle has a function, sdo_util.simplify that can simplify (generalize) the vertices describing a geometric object (that is, reduce the number in a way that maintains basic shape). However, that function only operates on a single geometry at a time. Using it on polygonal data that completely covers an area (planar enforced) can and will cause major deformation of the shapes destroying topological integrity. This article describes the problem and offers some solutions.

Here are some area shapes before simplification/generalisation. Note that the shared boundaries match with no gaps or overlaps.

Here are the same areas but after an unconstrained/non-topological simplification of each area independently of all others. Note that gaps and overlaps now occur.

Finally, here are the same areas but after a topologically constrained simplification/generalization. Note that boundaries still match with no overlaps and gaps.

**Simplifying an aggregation without breaking the ordinate limit**

Now, what would be nice is the ability to aggregate polygons and even if the result has more ordinates that Oracle can handle, simplify the resultant aggregate before returning it to Oracle. Now, this cannot be done as follows in the situation where the result of the SDO_AGGR_UNION breaks the SDO_ORDINATE_ARRAY limit:

SELECT SDO_UTIL.SIMPLIFY(SDO_AGGR_UNION(SDOAGGRTYPE(a.GEOM,0.0005)),25,0.0005) AS aggrPoly

I have provided this capability via a new set of methods in my SC4O package. I will demonstrate one of those methods now.

These are the polygons displayed using GeoRaptor that we will aggregate.

The aggregation with simplification is done via this simple call:

SELECT SC4O.ST_AggrUnionPolygons(CAST(COLLECT(a.GEOM) AS T_GeometrySet),3,25) AS aggrPoly FROM codesys.vegPolys a;

This uses a 3 decimal digit precision and a 25 meter simplification distance.

**NOTE:** The ST_AggrUnionPolygons function is designed to operate on projected data and not geographic (long/lat) data. If you have long/lat data (eg SRID = 8307) you can use the above function but the ordinate precision and the simplification distance must be specified in decimal degree units. If you can’t work out what something like 25m is in decimal degrees, I recommend you project your data into a suitable planar SRID to do the calculations and then project back. Assuming that vegPolys was geodetic, the new SQL would be:

SELECT sdo_cs.transform( SC4O.ST_AggrUnionPolygons(CAST(COLLECT(sdo_cs.transform(a.GEOM,28355)) AS T_GeometrySet),3,25), 8307) AS aggrPoly FROM codesys.vegPolys8307 a;

Either way, the following result should be produced:

Which, together with the original vegetation polygons looks like this:

## Documentation

- MySQL Spatial General Functions
- Oracle LRS Objects
- Oracle Spatial Exporter (Java + pl/SQL)
- Oracle Spatial Object Functions
- Oracle Spatial Object Functions (Multi Page)
- PostGIS pl/pgSQL Functions
- SC4O Oracle Java Topology Suite (Java + pl/SQL)
- SQL Server Spatial General TSQL Functions
- SQL Server Spatial LRS TSQL Functions