[postgis-users] Collecting Polygons

Obe, Regina robe.dnd at cityofboston.gov
Fri Jun 27 12:42:43 PDT 2008


Actually you can still get MULTIPOLYGONS with ST_Collect and ST_Collect tends to perform better the ST_Union, but doesn't dissolve.  If you just need MULTIPOLYGONS and no dissolving you might be better off with ST_Collect and dump. As described below.
 
http://postgis.refractions.net/pipermail/postgis-users/2008-June/020334.html
 
hope that helps,
Regina

________________________________

From: postgis-users-bounces at postgis.refractions.net on behalf of Lee Hachadoorian
Sent: Fri 6/27/2008 3:13 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Collecting Polygons



Interesting.  Very clear now that you showed me the SQL.  This was not
really clear to me from the docs.

Thanks,
--Lee

On Fri, Jun 27, 2008 at 3:00 PM, Kevin Neufeld <kneufeld at refractions.net> wrote:
> It merges all geometries you supply it.  If you supply geometries from
> different tables, then yes.
>
> SELECT ST_Union(geom)
> FROM (
>  SELECT geom FROM mytable1 WHERE ...
>  UNION ALL
>  SELECT geom FROM mytable2 WHERE ...
> ) AS foo;
>
> -- Kevin
>
> Lee Hachadoorian wrote:
>>
>> Thanks, Kevin, that worked.  I saw ST_Union, but I thought it was for
>> joining polygons from different spatial tables.  Does it do that also?
>>
>> --Lee
>>
>> On Fri, Jun 27, 2008 at 2:19 PM, Kevin Neufeld <kneufeld at refractions.net>
>> wrote:
>>>
>>> Hi Lee,
>>>
>>> If you want to merge several polygons together, dissolving them into a
>>> single polygon, then you'll want to use ST_Union() instead of
>>> ST_Collect().
>>>
>>> ST_Union() - returns the point set union of all input geometries,
>>> ST_Collect() - is a simple aggregate function that concatenates
>>> geometries
>>> together, ie a bunch of polygons to a multipolygon.
>>>
>>> -- Kevin
>>>
>>> Lee Hachadoorian wrote:
>>>>
>>>> Upgraded to 1.3.3 to get rid of previous problem with ST_Collect, but
>>>> I'm still not getting the output I want.  What I want to do is take
>>>> several polygons and mash them together into one polygon.  The SQL I
>>>> am using is:
>>>>
>>>> SELECT ST_Collect(the_geom)
>>>> FROM proj_mortgage.geo_hh_race
>>>> WHERE pct_hispanic > 50;
>>>>
>>>> But ST_Collect returns a GEOMETRYCOLLECTION, and I want a polygon or
>>>> multipolygon.  Do I need to do something with the GEOMETRYCOLLECTION
>>>> returned by ST_Collect, or is ST_Collect the wrong function to use in
>>>> the first place?
>>>>
>>>> Thanks,
>>>> Lee Hachadoorian
>>>> PhD Student, Geography
>>>> Program in Earth & Environmental Sciences
>>>> CUNY Graduate Center
>>>> _______________________________________________
>>>> postgis-users mailing list
>>>> postgis-users at postgis.refractions.net
>>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>
>>
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



--
Lee Hachadoorian
PhD Student, Geography
Program in Earth & Environmental Sciences
CUNY Graduate Center
_______________________________________________
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080627/3294828a/attachment.html>


More information about the postgis-users mailing list