[postgis-users] Collecting Polygons

Lee Hachadoorian lee.hachadoorian at gmail.com
Fri Jun 27 12:13:28 PDT 2008


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



More information about the postgis-users mailing list