<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Yes, this works great. <div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>UPDATE territories SET border = (SELECT ST_ConvexHull(ST_Collect(ST_GeomFromText('MULTIPOINT(-111.868842 50.569455, -111.898634 50.569992, -111.907919 50.583764, -111.868859 50.569452)') ) )) WHERE id = 3014;</div></div></blockquote><div><br></div><div>Now... I'm trying to figure out, how to do the same, except create the border (polygon) from points in another table, e.g.:</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> UPDATE territories SET border = (SELECT ST_ConvexHull(ST_Collect(
SELECT location FROM addresses WHERE territory_id = 3014
))) WHERE id = 3014;</span></div><div><br></div><div>...returns "ERROR:  function st_collect(geography) does not exist HINT:  No function matches the given name and argument types. You might need to add explicit type casts."</div><div><br></div><div>So I'm wondering, since both border (final polygon) and location (source of points) are of type geography, what's the best way to go about this? Or should I have just used geometry types? Sorry for the dumb questions, I'm trying to define the schemas by best practices so I don't have to fix them later. Geography seemed right when I started the project.</div><div><br></div><div><br></div><div><br></div><div><div><div>On 2012-09-11, at 1:18 AM, Paolo Corti wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Tue, Sep 11, 2012 at 3:44 AM, René Fournier <<a href="mailto:m5@renefournier.com">m5@renefournier.com</a>> wrote:<br><blockquote type="cite">Thanks Nicolas,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">UPDATE territories SET border =<br></blockquote><blockquote type="cite">ST_ConvexHull(ST_Collect(ST_GeomFromText('MULTIPOINT(50.569455 -111.868842,<br></blockquote><blockquote type="cite">50.569992 -111.898634, 50.583764 -111.907919, 50.569452 -111.868859)') ) )<br></blockquote><blockquote type="cite">WHERE id = 3014;<br></blockquote><blockquote type="cite">ERROR:  cannot use aggregate function in UPDATE<br></blockquote><blockquote type="cite">LINE 1: UPDATE territories SET border = ST_ConvexHull(ST_Collect(ST_...<br></blockquote><blockquote type="cite"><br></blockquote><br>Using a sub-select should work:<br><br>UPDATE territories SET border = (SELECT<br>ST_ConvexHull(ST_Collect(ST_GeomFromText('MULTIPOINT(50.569455<br>-111.868842, 50.569992 -111.898634, 50.583764 -111.907919, 50.569452<br>-111.868859)') ) ))<br>WHERE id = 3014;<br><br>regards<br>p<br><br>-- <br>Paolo Corti<br>Geospatial software developer<br>web: <a href="http://www.paolocorti.net">http://www.paolocorti.net</a><br>twitter: @capooti<br>skype: capooti<br>_______________________________________________<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>