See https://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html
DissolvePoints
a Geometry (actually corresponding to a POINT or MULTIPOINT) will be
returned.¨
The input Geometry is arbitrary: any POINT will remain unaffected, but
any LINESTRING or RING will be dissolved into elementary Points
corresponding to each Vertex.
NULL will be returned if any error is encountered
If the result is a MultiPolygon it can be split into a set of points with ElementaryGeometries
Will create a new out_table directly corresponding to in_table. The
output table will be arranged in such a way that each row will always
contain an elementary Geometry; so each time that a MULTI-type
Geometry is found in the input table it will be split into many
distinct rows.
Because the function takes a table as input the multipoints from DissolvePoints must be saved into a table first. The full synopsis of ElementaryGeometries is
ElementaryGeometries( in_table Text , geom_column Text , out_table Text , out_pk Text , out_multi_id Text ) : Integer
I tested that with the following steps I could create a point table that has referenced to the id of the original multipolygon. However, it is not possible to get an index for rings with ElementaryGeometries, and for getting an index for polygon parts in a multipolygon ElementaryGeometries should be used two times:
- explode multipolygon into a polygon table with ElementaryGeometries
- use DissolvePoints for the single polygons
- explode the MultiPoints with ElementaryGeometries
The three steps to make a Point layer "points" from a MultiPolygon layer "multi" in SpatiaLite.
create table temp as
select ogc_fid,DissolvePoints(geometry) as geometry
from multi;
select RecoverGeometryColumn(
'temp','geometry',0,'GEOMETRY');
select ElementaryGeometries(
'temp','geometry','points','point_id','source_id');
In this example the primary key is "ogc_fid" and SRID=0 but the SQL must be adopted to match with the real data.