Thanks Nicolas,

I've gotten a bit farther. Stuck again though. This works:

        SELECT 
ST_AsText(ST_ConvexHull(ST_Collect(ST_GeomFromText('MULTIPOINT(50.569455 
-111.868842, 50.569992 -111.898634, 50.583764 -111.907919, 50.569452 
-111.868859)') ) ));
                                                        st_astext               
                                          
--------------------------------------------------------------------------------------------------------------------------
 POLYGON((50.583764 -111.907919,50.569992 -111.898634,50.569452 
-111.868859,50.569455 -111.868842,50.583764 -111.907919))

But for some reason, I can't update:

UPDATE territories SET border = 
ST_ConvexHull(ST_Collect(ST_GeomFromText('MULTIPOINT(50.569455 -111.868842, 
50.569992 -111.898634, 50.583764 -111.907919, 50.569452 -111.868859)') ) ) 
WHERE id = 3014;
ERROR:  cannot use aggregate function in UPDATE
LINE 1: UPDATE territories SET border = ST_ConvexHull(ST_Collect(ST_...

Any ideas? I'm new to these functions.. Ultimately, I want to update territory 
with a set of points from a SELECT, e.g.:

        SELECT location FROM addresses WHERE territory_id = 3014;

                                                   Table "public.addresses"
     Column      |           Type           |                       Modifiers   
                     | Storage  | Description 
-----------------+--------------------------+--------------------------------------------------------+----------+-------------
 id              | integer                  | not null default 
nextval('addresses_id_seq'::regclass) | plain    | 
 territory_id    | integer                  | not null                          
                     | plain    | 
 location        | geography(Point,4326)    |                                   
                     | main     | 


On 2012-09-10, at 12:46 PM, Nicolas Ribot wrote:

> Hi,
> 
> You could use st_convexHull on the point set and then buffer it with 
> st_buffer.
> (st_concaveHull may give you better results on polygon approximation
> (see: 
> http://postgis.refractions.net/documentation/manual-2.0/ST_ConcaveHull.html)
> 
> Nicolas
> 
> On 10 September 2012 20:39, René Fournier <m...@renefournier.com> wrote:
>> I've written a script to migrate location data from MySQL to PostGIS.
>> Each region contains 5-20 locations. I would like my script to create a 
>> simple polygon for each region that encompasses its locations (lat/lng 
>> points). I say simple in the sense of not too many vertices (< 10), even if 
>> the region contains 20 points.(The easiest thing would be a bounding box, 
>> but I would like it a bit more defined than that.)  Additionally, I would 
>> like the polygon to be a bit bigger (say, by 10 meters) than the points it 
>> contains.
>> 
>> Just wondering if this is something that can be done in a PostGIS query or 
>> PHP using some algorithm for simple. What would you recommend? Thanks!
>> 
>> ...Rene
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users@postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to