[postgis-users] st_intersection() outputs multipolygons
Kevin Neufeld
kneufeld at refractions.net
Thu Apr 24 18:37:34 PDT 2008
Hi Dylan,
This is normal behaviour.
ST_Intersection returns the intersection of two geometries. In your
case involving two polygons, this can return a point, linestring,
polygon, multipoint, multilinestring, multipolygon, or a collection of
some or all of these. It totally depends on how your input geometries
interact with eachother.
If you think your output is in error, narrow down your input datasets to
a simple test case. So we can help you further, post your input here in
wkt format (if it's not too large) and let us know what you were
expecting to see.
Cheers,
Kevin
Dylan Beaudette wrote:
> Hi,
>
> I have two imput tables with all polygon geometry types, all polygons are
> reported as valid. After performing an intersection, I am left with mixed
> polygon and multipolygon geometry types:
>
> CREATE TABLE dwr.mapunit_dau as
> SELECT m_polys.areasymbol, m_polys.mukey, d_polys.dau_id,
> ST_Intersection(d_polys.wkb_geometry, m_polys.wkb_geometry) as wkb_geometry
> FROM
> (
> -- subset map unit polygons to certain survey areas
> -- 6.540 s
> SELECT wkb_geometry, areasymbol, mukey
> FROM mapunit_poly
> -- results in 21682 map unit polygons
> WHERE areasymbol in ('ca653', 'ca654', 'ca113')
> ) as m_polys
> JOIN
> (
> -- subset DAU polygons that overlap with specific survey areas
> -- 512 ms
> SELECT dwr.dau.wkb_geometry, dau.dau3_d_id as dau_id
> FROM dwr.dau JOIN mapunit_bound_poly
> -- results in 58 DAU polygons
> ON mapunit_bound_poly.areasymbol in ('ca653', 'ca654', 'ca113')
> and dwr.dau.wkb_geometry && mapunit_bound_poly.wkb_geometry
> ) as d_polys
> -- join condition: only those polygons which completely intersect
> ON ST_Intersects(d_polys.wkb_geometry, m_polys.wkb_geometry);
>
>
> --
> --
> --
> Looking at the results, I have several geometry types with several total
> geometries per original feature:
>
> SELECT DISTINCT GeometryType(wkb_geometry), ST_NumGeometries(wkb_geometry)
> from mapunit_dau;
>
> geometrytype | st_numgeometries
> --------------+------------------
> MULTIPOLYGON | 2
> MULTIPOLYGON | 3
> MULTIPOLYGON | 4
> MULTIPOLYGON | 5
> MULTIPOLYGON | 6
> MULTIPOLYGON | 7
> MULTIPOLYGON | 8
> MULTIPOLYGON | 9
> MULTIPOLYGON | 10
> MULTIPOLYGON | 11
> MULTIPOLYGON | 12
> MULTIPOLYGON | 13
> MULTIPOLYGON | 14
> MULTIPOLYGON | 15
> MULTIPOLYGON | 16
> MULTIPOLYGON | 18
> MULTIPOLYGON | 21
> MULTIPOLYGON | 24
> MULTIPOLYGON | 26
> MULTIPOLYGON | 27
> MULTIPOLYGON | 32
> MULTIPOLYGON | 36
> MULTIPOLYGON | 41
> MULTIPOLYGON | 52
> MULTIPOLYGON | 56
> MULTIPOLYGON | 69
> POLYGON |
>
> I have checked, and these multipolygons represent large features, not
> sliver-like artifacts that are commonly left-over from an intersection. Also,
> they contain useful information (non-overlapping polygons) as I traverse the
> geometry tree with GeometryN()...
>
> Any ideas?
>
> Cheers,
>
> Dylan
>
>
More information about the postgis-users
mailing list