I am actually wondering how I can know the extents of this grid? So basically I have some other<div>data set that has lat/long points. I will project them to the same as this buffer/grid solution so that</div><div>from the points in that other data set I can just compute which grid cell they belong to. So for </div>
<div>that I need to know what is the grid's top-left corner's lat/long right? And then it should just be a </div><div>matter of calculating which grid cell a certain lat/long point should belong to.</div><div><br>
</div><div> <br><br><div class="gmail_quote">On Wed, Mar 21, 2012 at 9:53 PM, Ed Linde <span dir="ltr"><<a href="mailto:edolinde@gmail.com">edolinde@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks Pierre for the detailed information. I will give this a shot tomorrow and see how it goes! :)<div class="HOEnZb"><div class="h5"><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" target="_blank">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><div>> 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" target="_blank">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>
</div></div></blockquote></div><br></div>