<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks Nicolas,<div><br></div><div>I've gotten a bit farther. Stuck again though. This works:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        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))</span><span class="Apple-tab-span" style="white-space:pre">
</span></div><div><br></div><div>But for some reason, I can't update:</div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><br></div><div><div>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;</div></div><div><div>ERROR:  cannot use aggregate function in UPDATE</div></div><div><div>LINE 1: UPDATE territories SET border = ST_ConvexHull(ST_Collect(ST_...</div></div></blockquote><div><br></div><div>Any ideas? I'm new to these functions.. Ultimately, I want to update territory with a set of points from a SELECT, e.g.:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span>SELECT location FROM addresses WHERE territory_id = 3014;</div><div><br></div><div><div>                                                   Table "public.addresses"</div><div>     Column      |           Type           |                       Modifiers                        | Storage  | Description </div><div>-----------------+--------------------------+--------------------------------------------------------+----------+-------------</div><div> id              | integer                  | not null default nextval('addresses_id_seq'::regclass) | plain    | </div><div> territory_id    | integer                  | not null                                               | plain    | </div><div> location        | geography(Point,4326)    |                                                        | main     | </div><div><br></div></div><div><br></div><div><div><div>On 2012-09-10, at 12:46 PM, Nicolas Ribot wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi,<br><br>You could use st_convexHull on the point set and then buffer it with st_buffer.<br>(st_concaveHull may give you better results on polygon approximation<br>(see: <a href="http://postgis.refractions.net/documentation/manual-2.0/ST_ConcaveHull.html">http://postgis.refractions.net/documentation/manual-2.0/ST_ConcaveHull.html</a>)<br><br>Nicolas<br><br>On 10 September 2012 20:39, René Fournier <<a href="mailto:m5@renefournier.com">m5@renefournier.com</a>> wrote:<br><blockquote type="cite">I've written a script to migrate location data from MySQL to PostGIS.<br></blockquote><blockquote type="cite">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.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">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!<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">...Rene<br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">postgis-users mailing list<br></blockquote><blockquote type="cite"><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br></blockquote><blockquote type="cite"><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></blockquote>_______________________________________________<br>postgis-users mailing list<br><a href="mailto:postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br>http://postgis.refractions.net/mailman/listinfo/postgis-users<br></div></blockquote></div><br></div></body></html>