I have a table that contains buildings in a line geometry where a line starts and ends at the same point. Is there away to convert lines to polygons in Oracle Spatial?
[GIS] Line to polygon in Oracle Spatial
linestringoracle-spatialpolygonsql
Related Question
- [GIS] Extracting data from Oracle Spatial and preserving spatial data
- [GIS] How to find overlapping polygons within a multipolygon (Oracle spatial)
- [GIS] Finding Polygons which do not touch any other polygon in a single oracle database table
- [GIS] How to convert a compound geometry (Oracle) to a geometry made of straight line segments only
Best Answer
This solution works for linestrings with not too much vertices (which should be the case for most buildings):
The function just replaces the linestring WKT (
SDO_UTIL.FROM_WKTGEOMETRY
) with polygon WKT and returns it as a geometry (SDO_UTIL.TO_WKTGEOMETRY
). Note that this function will break for linestrings with a lot of vertices because the length of a VARCHAR2 is limited to 4000. Also you have to make sure that the line is really closed!UPDATE - Better solution
The following is a better solution that does not have the previous limitation:
Of course you still have to make sure that your linestrings are really closed!