Converting Multipolygon to Polygon

2,035 views
Skip to first unread message

jajd

unread,
Jun 10, 2010, 7:44:54 AM6/10/10
to SpatiaLite Users
Is there a way to convert a Table containing MULTIPOLYGONs to a table
containing POLYGONs?

Keith

unread,
Jun 11, 2010, 8:58:40 AM6/11/10
to SpatiaLite Users

jajd

unread,
Jun 23, 2010, 5:03:08 AM6/23/10
to SpatiaLite Users
That works only if the multipolygon contains one polygon as
documented.

spatialite> select
AsText(CastToPolygon(MultipolygonFromText('MULTIPOLYGON(((0 1, 1 2, 1
1, 0 1)),((3 4, 4 5, 4 4, 3 4)))')));

(nothing is returned here)
spatialite> select
AsText(CastToPolygon(MultipolygonFromText('MULTIPOLYGON(((0 1, 1 2, 1
1, 0 1)))')));
POLYGON((0 1, 1 2, 1 1, 0 1))
(works OK if the multipolygon contains one polygon)
spatialite>

I need something that gives a set of results
POLYGON((0 1, 1 2, 1 1, 0 1))
POLYGON((3 4, 4 5, 4 4, 3 4))
> > containing POLYGONs?- Hide quoted text -
>
> - Show quoted text -

a.furieri

unread,
Jun 23, 2010, 5:49:43 AM6/23/10
to SpatiaLite Users
Hi,
your question is now clear.

Answer:
========
NO, there is no way to do what you
intend using plain SQL.

And the reason is elementary simple:
you are actually requesting that
a single entity (row/cell) will be
'implicitly/silently' split into
multiple entities (aka rows)
but this is strongly conflicting with
the SQL data model itself

Suggestion
==========
you can anyway perform this task in
a quite simple fashion, but you need
to do this following the programmatic
way.
you can write (by your own) some C code,
using the C-API.
I suppose something like can be done
using Python as well.

bye
Sandro

Greg Krakow

unread,
Apr 6, 2019, 11:18:07 AM4/6/19
to SpatiaLite Users
Currently you can use the ElementaryGeometries SpatiaLite function for this.
Reply all
Reply to author
Forward
0 new messages