0

Is there an equivalent to the PostGIS ST_MULTI available in Oracle Spatial?

or

How can I convert POLYGON to MULTIPOLYGON in Oracle spatial?

2
  • 1
    Can you explain why this would be necessary? What benefit would you achieve through this process?
    – Vince
    Dec 2, 2013 at 14:58
  • There is an application which is expecting multipolygons (instead of geometry), but I have polygon and multipolygon mixed in the db column. Now I need to clean up the data until the application is ready to accept both types.
    – ABX
    Dec 2, 2013 at 15:08

2 Answers 2

3

You mean you have a table that contains a mix of polygons (SDO_GTYPE 2003) and multi-polygons (SDO_GTYPE 2007) and your application cannot handle that mix, i.e. it requires the input to be all SDO_GTYPE 2007 ?

Like Vince said, you need to fix your application. I see no reason for such a requirement.

Otherwise, you can actually force the SDO_TYPE of the existing data by making them all appear to be multi-polygons, by doing this:

update my_table t
set t.my_geometry.sdo_gtype=2007
where t.my_geometry.sdo_gtype=2003;

If the table is large and contains many 2003 geometries, then you may want to first drop the spatial index before doing the update (and re-create it afterwards).

Now your table will contain true multi-polygons (that contain multiple polygons) and others that look like multi-polygons but that actually contain just one polygon. After all you can argue that a multi-polygon with one polygon is just a special case of a multi-polygon :-).

Hopefully that will make your application happy. As for the database and Oracle Spatial, they will be happy too.

2
  • well, there is a reason for this requirement. If You create geometries with the oracle function sdo_aggr_union, Oracle creates polygons (2003) and multi polygons (2007) depending on the result. You cannot force the function to create a multi polygon if it contains just one polygon.
    – ABX
    Dec 3, 2013 at 9:21
  • Still, what does it matter ? If there is only one polygon to aggregate, then the result will be a single polygon - a 2003. So what ? That is a perfectly valid shape that can be used for any other purpose. Dec 7, 2013 at 14:55
2

Your best solution is to fix the application, unless corrupting the single-part geometries by adding tiny holes with tinier islands or adding an out-of-bounds part to all geometries holds allure.

Not the answer you're looking for? Browse other questions tagged or ask your own question.