<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi Rene,<br><br>Perhaps something like this?<br><br>select region, ST_simplify(ST_buffer(ST_convexhull(ST_collect(geom), n),n/3)) from table group by region;<br><br><br>ST_simplify removes extraneous vertices - increase the n/3 parameter to remove more vertices, but you'll also need to increase n to ensure all the points lie within the simplified polygon - you don't have to use n/3, just a value off the top of my head<br><br>ST_buffer will create a new polygon distance n outside the original one<br><br>ST_convexhull will create a polygon encompassing the points. ST_concavehull might also work, but I've found it problematic.<br><br>ST_collect will create a group of points to work with<br><br>all grouped by region.<br><br><br><br>HTH,<br><br>   Brent Wood<br><br><br>--- On <b>Tue, 9/11/12, René Fournier <i><m5@renefournier.com></i></b>
 wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: René Fournier <m5@renefournier.com><br>Subject: [postgis-users] Creating a simple polygon encompassing a given number of points<br>To: "PostGIS Users Discussion" <postgis-users@postgis.refractions.net><br>Date: Tuesday, September 11, 2012, 6:39 AM<br><br><div class="plainMail">I've written a script to migrate location data from MySQL to PostGIS.<br>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><br>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><br>...Rene<br>_______________________________________________<br>postgis-users mailing list<br><a ymailto="mailto:postgis-users@postgis.refractions.net" href="/mc/compose?to=postgis-users@postgis.refractions.net">postgis-users@postgis.refractions.net</a><br><a href="http://postgis.refractions.net/mailman/listinfo/postgis-users" target="_blank">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></blockquote></td></tr></table>