[postgis-users] GeometryCollection after ST_Centroid(ST_Dump)

Chris Hermansen chris.hermansen at timberline.ca
Tue Oct 14 09:20:43 PDT 2008


Is it possible the GROUP BY produces geometry collections when there are
multiple geometries returned?  That seems at least plausible to me.

Maybe if you try to look at what's returned with and without the GROUP
BY in the cases where multiple geometries are returned (HAVING would
help there).

Obe, Regina wrote:
> Birgit,
>
> So you are saying ST_Centroid sometimes returns geometry collections.
> Hmm I don't see how that is possible unless there is bug somewhere.
>
> Can you provide an example of that.  Regarding the below query - it
> would be a bit easier to follow if you did a subselect first.
>
> Something like
>
>  SELECT
>   abdump.gid,
>   abdump.objart_07,
>  abdump.cat_07,
> ST_X(ST_Centroid(abdump.newgeom)) As x_centroid,
> ST_Y(ST_Centroid(abdump.newgeom)) As y_centroid
> ST_Area(ST_Centroid(abdump.newgeom)) As area,
> ST_Perimeter(ST_Centroid(abdump.newgeom)) as perimeter
> FROM (SELECT (ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom As newgeom, a.gid, a.objart_07, a.cat_07, a.the_geom
> as a_the_geom, b.the_geom as b_the_geom
> FROM 
>  bfn.test_mv_dlm07 a, bfn.test_mv_dlm07 b
> WHERE ST_Overlaps(a.the_geom,b.the_geom)=true AND 
> Intersects(a.the_geom,b.the_geom)=true
> ) As abdump
> GROUP BY ST_X(ST_Centroid(abdump.newgeom)), 
> ST_Y(ST_Centroid(abdump.newgeom)), ST_Area(ST_Centroid(abdump.newgeom)),
>
> ST_Perimeter(ST_Centroid(abdump.newgeom)), abdump.gid, abdump.objart_07,
> abdump.cat_07, a_the_geom, b_the_geom
> ORDER BY x_centroid asc, y_centroid asc, area asc, perimeter asc, a.gid
> asc;
>
> Hope that helps,
> Regina
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of
> Birgit Laggner
> Sent: Tuesday, October 14, 2008 6:56 AM
> To: PostGIS Users Discussion
> Subject: [postgis-users] GeometryCollection after ST_Centroid(ST_Dump)
>
> Dear list,
>
> I have a SELECT statement in which I try to group by the polygons 
> resulting from a self intersection. After I realized that I can't group 
> by the_geom because this would group polygons which are only similar but
>
> not equal, I decided to group by the area, the perimeter and the x- and 
> y-coordinates of the centroid of every polygon. The SELECT statement I 
> wrote, worked so far for some test datasets and showed seemingly 
> reasonable results. But for at least one of my datasets, the statement 
> does not work, because the ST_Centroid produces some GeometryCollections
>
> instead of POINTS. What could cause that problem and how can I solve
> it???
>
> This is my statement:
>
> SELECT
>   a.gid,
>   a.objart_07,
>   a.cat_07,
>   ST_X(ST_Centroid((ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom)) as x_centroid,
>   ST_Y(ST_Centroid((ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom)) as y_centroid,
>   ST_Area((ST_Dump(ST_Intersection(a.the_geom, b.the_geom))).geom) as
> area,
>   ST_Perimeter((ST_Dump(ST_Intersection(a.the_geom, b.the_geom))).geom) 
> as perimeter,
>   (ST_Dump(ST_Intersection(a.the_geom, b.the_geom))).geom as the_geom
> FROM bfn.test_mv_dlm07 a, bfn.test_mv_dlm07 b
> WHERE ST_Overlaps(a.the_geom,b.the_geom)=true AND 
> Intersects(a.the_geom,b.the_geom)=true
> GROUP BY ST_X(ST_Centroid((ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom)), 
> ST_Y(ST_Centroid((ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom)), ST_Area((ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom), ST_Perimeter((ST_Dump(ST_Intersection(a.the_geom, 
> b.the_geom))).geom), a.gid, a.objart_07, a.cat_07, a.the_geom,
> b.the_geom
> ORDER BY x_centroid asc, y_centroid asc, area asc, perimeter asc, a.gid
> asc;
>
> The ST_Dump results in POLYGONs, LINESTRINGs and POINTs.
>
> Thank you for any help!
>
> Regards,
>
> Birgit.
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> -----------------------------------------
> The substance of this message, including any attachments, may be
> confidential, legally privileged and/or exempt from disclosure
> pursuant to Massachusetts law. It is intended
> solely for the addressee. If you received this in error, please
> contact the sender and delete the material from any computer.
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>   


-- 
Regards,

Chris Hermansen         mailto:chris.hermansen at timberline.ca
tel+1.604.714.2878 · fax+1.604.733.0631 · mob+1.778.232.0644
Timberline Natural Resource Group · http://www.timberline.ca
401 · 958 West 8th Avenue  · Vancouver BC · Canada · V5Z 1E5




More information about the postgis-users mailing list