Thanks Pierre for the detailed information. I will give this a shot tomorrow and see how it goes! :)<br><br><div class="gmail_quote">On Wed, Mar 21, 2012 at 8:46 PM, Pierre Racine <span dir="ltr"><<a href="mailto:Pierre.Racine@sbf.ulaval.ca">Pierre.Racine@sbf.ulaval.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">> I am not sure if this is possible, but I have computed (using ST_Buffer) a sort of<br>
> buffer around several LINESTRINGs. Now I would like to lay some sort of grid of<br>
> say 1m^2 cell size on top of this collection of geometries and then compute the<br>
> intersection... so in the end I would like to for example, know that grid cell ID = 1<br>
> intersects with buffers 1 and 10, grid cell 2 intersects with buffers 7, 10 etc..<br>
><br>
> Is there a simple way of doing this in postgis? Maybe someone could point me to<br>
> some documentation of how I can generate such a grid in postgis and maybe<br>
> then I can use just ST_Intersect once I have these two geometries?<br>
<br>
</div></div>With the raster type you can now easily create a vector grid like this:<br>
<br>
CREATE TABLE vectorgrid AS<br>
SELECT (gvxy).geom, ((gvxy).x - 1) * rwidth + (gvxy).y gridid<br>
FROM (SELECT ST_PixelAsPolygons(rast) gvxy, ST_Width(rast) rwidth<br>
FROM (SELECT ST_AsRaster(ST_Extent(geom)::geometry, 1.0, 1.0) rast<br>
FROM yourbuffertable<br>
) foo1<br>
) foo2;<br>
<br>
Make sure a spatial index exist on both tables:<br>
<br>
CREATE INDEX yourbuffertable_geom_idx ON yourbuffertable USING gist (geom);<br>
CREATE INDEX vectorgrid _geom_idx ON vectorgrid USING gist (geom);<br>
<br>
You can then perform a normal intersect query:<br>
<br>
CREATE TABLE interresult AS<br>
SELECT b.bufferid, g.gridid, ST_Intersection(g.geom, b.geom) geom<br>
FROM vectorgrid g, yourbuffertable b<br>
WHERE ST_Intersects(g.geom, b.geom);<br>
<br>
Pierre<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto: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>
</blockquote></div><br>