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)
Removing Steps in Gridded Vector Data – SmoothGrid for Oracle
Many vector datasets are created from remote sensed imagery. If the conversion processes does not remove the “steps” in the boundaries of the created polygons the data can not only look “unreal” it can also greatly increase the complexity of the resultant polygons (and thus the number of vertices and size of the stored object) if no attempt is made to “smooth” or “de-Step” the data.
Here is an example, test multipolygon that is in need of “smoothing”:
I have created a PL/SQL function called “smoothGrid” (As I can’t think of another name that would be more grammatical – try UnStepGriddedPolygon – I think not) that smooths the multipolygon’s edges:
CREATE OR REPLACE FUNCTION GRIDSMOOTH ( P_GEOMETRY IN MDSYS.SDO_GEOMETRY ) RETURN mdsys.sdo_geometry deterministic
That when applied to the gridded data above produces the following result.
select gridSmooth(geom) as geom from (select MDSYS.SDO_GEOMETRY('MULTIPOLYGON(((-250.0 3850.0, 750.0 3850.0,1750.0 3850.0,1750.0 2850.0,2750.0 2850.0,3750.0 2850.0, 3750.0 1850.0,2750.0 1850.0,2750.0 850.0,1750.0 850.0,1750.0 -150.0, 2750.0 -150.0,3750.0 -150.0,4750.0 -150.0,5750.0 -150.0,5750.0 850.0, 6750.0 850.0,6750.0 1850.0,6750.0 2850.0,5750.0 2850.0,5750.0 3850.0, 4750.0 3850.0,4750.0 4850.0,4750.0 5850.0,5750.0 5850.0,6750.0 5850.0, 6750.0 4850.0,7750.0 4850.0,7750.0 3850.0,7750.0 2850.0,9750.0 2850.0, 9750.0 3850.0,9750.0 4850.0,9750.0 5850.0,8750.0 5850.0,8750.0 6850.0, 7750.0 6850.0,7750.0 7850.0,6750.0 7850.0,6750.0 8850.0,6750.0 9850.0, 5750.0 9850.0,4750.0 9850.0,4750.0 8850.0,3750.0 8850.0,3750.0 7850.0, 2750.0 7850.0,2750.0 6850.0,1750.0 6850.0,1750.0 5850.0,750.0 5850.0, 750.0 4850.0,-250.0 4850.0,-250.0 3850.0),(1250.0 4350.0,1250.0 5350.0, 2250.0 5350.0,2250.0 6350.0,3250.0 6350.0,3250.0 7350.0,4250.0 7350.0, 4250.0 8350.0,5250.0 8350.0,5250.0 7350.0,5250.0 6350.0,4250.0 6350.0, 4250.0 5350.0,3250.0 5350.0,3250.0 4350.0,2250.0 4350.0,1250.0 4350.0)), ((-500.0 5100.0,500.0 5100.0,500.0 6100.0,1500.0 6100.0,1500.0 7100.0, 2500.0 7100.0,2500.0 8100.0,3500.0 8100.0,3500.0 9100.0,2500.0 9100.0, 1500.0 9100.0,1500.0 8100.0,500.0 8100.0,500.0 7100.0,-500.0 7100.0, -500.0 6100.0,-500.0 5100.0)))',null) as geom from dual);
The savings in the number of stored points can be generated as follows:
select geomSmoothCount,original_count,ROUND( (geomSmoothCount / original_count) * 100,0) as saving from ( select mdsys.sdo_util.getNumVertices(gridSmooth(geom)) as geomSmoothCount, mdsys.sdo_util.getNumVertices(geom) as original_count from (select MDSYS.SDO_GEOMETRY('MULTIPOLYGON(((-250.0 3850.0, 750.0 3850.0,1750.0 3850.0,1750.0 2850.0,2750.0 2850.0,3750.0 2850.0, 3750.0 1850.0,2750.0 1850.0,2750.0 850.0,1750.0 850.0,1750.0 -150.0, 2750.0 -150.0,3750.0 -150.0,4750.0 -150.0,5750.0 -150.0,5750.0 850.0, 6750.0 850.0,6750.0 1850.0,6750.0 2850.0,5750.0 2850.0,5750.0 3850.0, 4750.0 3850.0,4750.0 4850.0,4750.0 5850.0,5750.0 5850.0,6750.0 5850.0, 6750.0 4850.0,7750.0 4850.0,7750.0 3850.0,7750.0 2850.0,9750.0 2850.0, 9750.0 3850.0,9750.0 4850.0,9750.0 5850.0,8750.0 5850.0,8750.0 6850.0, 7750.0 6850.0,7750.0 7850.0,6750.0 7850.0,6750.0 8850.0,6750.0 9850.0, 5750.0 9850.0,4750.0 9850.0,4750.0 8850.0,3750.0 8850.0,3750.0 7850.0, 2750.0 7850.0,2750.0 6850.0,1750.0 6850.0,1750.0 5850.0,750.0 5850.0, 750.0 4850.0,-250.0 4850.0,-250.0 3850.0),(1250.0 4350.0,1250.0 5350.0, 2250.0 5350.0,2250.0 6350.0,3250.0 6350.0,3250.0 7350.0,4250.0 7350.0, 4250.0 8350.0,5250.0 8350.0,5250.0 7350.0,5250.0 6350.0,4250.0 6350.0, 4250.0 5350.0,3250.0 5350.0,3250.0 4350.0,2250.0 4350.0,1250.0 4350.0)), ((-500.0 5100.0,500.0 5100.0,500.0 6100.0,1500.0 6100.0,1500.0 7100.0, 2500.0 7100.0,2500.0 8100.0,3500.0 8100.0,3500.0 9100.0,2500.0 9100.0, 1500.0 9100.0,1500.0 8100.0,500.0 8100.0,500.0 7100.0,-500.0 7100.0, -500.0 6100.0,-500.0 5100.0)))',null) as geom from dual) );
GEOMSMOOTHCOUNT | ORIGINAL_COUNT | SAVING |
---|---|---|
39 | 88 | 44 |
If anyone is interested in this function, contact me.
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