# How to convert a compound geometry (Oracle) to a geometry made of straight line segments only?

I have an Oracle Spatial table containing compound geometries (i.e. geometries containing both straight lines segments and arcs) that I want to project in another reference system.

Using `SDO_CS.TRANSFORM` returns:

``````13294. 00000 -  "cannot transform geometry containing circular arcs"
*Cause:    It is impossible to transform a 3-point representation of
a circular arc without distortion.
*Action:   Make sure a geometry does not contain circular arcs.
``````

Is there a way to convert the arcs to straight lines with a SQL request?

I've read Converting arcs to straight line segments? which mentions using FME or ArcGIS Desktop to do the conversion but I don't have access to such tools. What I am looking for is a way to do that only with Oracle Spatial (I do not care if the resulting segments are raw approximations of the original geometries).

• Search from the web found SDO_GEOM.SDO_ARC_DENSIFY docs.oracle.com/cd/E11882_01/appdev.112/e11830/…. I would try that. – user30184 May 3 '16 at 9:25
• Could you write some notes about how you used SDO_GEOM.SDO_ARC_DENSIFY? I haven't tried it myself yet. – user30184 May 3 '16 at 14:03
• @user30184 The function takes a tolerance parameter as second parameter (which defines a minimum difference distance in original projection units under which coordinates are considered the same, and a string to define an arc_tolerance (explained on your link), in the end `SDO_GEOM.SDO_ARC_DENSIFY(GEOMETRIE, 0.1, 'arc_tolerance=0.05 unit=km')` made my day. – jeremy-george May 3 '16 at 14:09

## 1 Answer

The function that converts arc into straight segments is SDO_GEOM.SDO_ARC_DENSIFY. Documentation for Oracle 12c is at http://docs.oracle.com/database/121/SPATL/GUID-97E8BF76-34B8-48CA-94A4-96F16B01B60C.htm#SPATL1108

There are two formats for the function

``````SDO_GEOM.SDO_ARC_DENSIFY(
geom    IN SDO_GEOMETRY,
dim     IN SDO_DIM_ARRAY
params  IN VARCHAR2
) RETURN SDO_GEOMETRY;
``````

or

``````SDO_GEOM.SDO_ARC_DENSIFY(
geom    IN SDO_GEOMETRY,
tol     IN NUMBER
params  IN VARCHAR2
) RETURN SDO_GEOMETRY;
``````

Diminfo is rather painful to write by hand and therefore the latter format suits better for ad hoc queries.

An usage example with tolerance=0.1 (vertices which are closer that 0.1 meter from each other are considered to be in the same place) and arc_tolerance of 50 m (at maximum 50 meters shift is accepted due to conversion of curve into polyline)

``````SDO_GEOM.SDO_ARC_DENSIFY(GEOMETRIE, 0.1, 'arc_tolerance=0.05 unit=km')
``````