[postgis-users] Need a "polygon box" of a table instead of the bounding box that returns extent function

Nicolas Ribot nicolas.ribot at gmail.com
Wed May 5 01:52:15 PDT 2010

On 5 May 2010 02:38, Oscar Zamudio <cmntlk at gmail.com> wrote:
> Well, it works like a charm!
> But I still need some advise. The query generates a polygon and I use astext
> to get readable output. Now I create a new table that will contain a name
> and the geometry result of the query. I want to use something like:
> INSERT INTO boundaries ( the_geom, the_name ) VALUES (SELECT
> ST_ConvexHull(ST_Collect(the_geom)) as the_geom from my_street_table),
> 'mytablename');
> This can't work but I don't know how to do it better.
> By now I first returned the polygon as text and then did the following:
> INSERT INTO boundaries ( the_geom, the_name ) VALUES
> (ST_GeomFromText('POLYGON((-58.8714168974345
> -34.5696042275729,-58.9620017725354 .......))'), 'mytablename');
> With this and pgsql2shp I generated a shapefile for the boundary. I could
> draw the streets (original shapefile) and the boundary both together and
> they match perfect!
> Please excuse me if I am making a silly question but I'm a newbie.
> Thanks in advance

I'm not sure I understand your question.
You want to find the INSERT syntax allowing to use a query to provide
the table with values ?

INSERT also accepts a query to get the values

NSERT INTO boundaries ( the_geom, the_name )
SELECT ST_ConvexHull(ST_Collect(the_geom)) as the_geom, 'mytablename'
from my_street_table;


More information about the postgis-users mailing list