SELECT ST_AsText ((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(way_geom)::geometry, 0.000036, 0.000036) rast<br>
FROM buffers<br> where osm_id = 98729854<br> ) foo1<br> ) foo2;<br><br><br>"POLYGON((11.1539754732244 55.5772503545236,11.1540114732244 55.5772503545236,11.1540114732244 55.5772863545236,11.1539754732244 55.5772863545236,11.1539754732244 55.5772503545236))";1<br>
"POLYGON((11.1540114732244 55.5772503545236,11.1540474732244 55.5772503545236,11.1540474732244 55.5772863545236,11.1540114732244 55.5772863545236,11.1540114732244 55.5772503545236))";10<br>"POLYGON((11.1540474732244 55.5772503545236,11.1540834732244 55.5772503545236,11.1540834732244 55.5772863545236,11.1540474732244 55.5772863545236,11.1540474732244 55.5772503545236))";19<br>
"POLYGON((11.1540834732244 55.5772503545236,11.1541194732244 55.5772503545236,11.1541194732244 55.5772863545236,11.1540834732244 55.5772863545236,11.1540834732244 55.5772503545236))";28<br>"POLYGON((11.1541194732244 55.5772503545236,11.1541554732244 55.5772503545236,11.1541554732244 55.5772863545236,11.1541194732244 55.5772863545236,11.1541194732244 55.5772503545236))";37<br>
"POLYGON((11.1541554732244 55.5772503545236,11.1541914732244 55.5772503545236,11.1541914732244 55.5772863545236,11.1541554732244 55.5772863545236,11.1541554732244 55.5772503545236))";46<br>"POLYGON((11.1541914732244 55.5772503545236,11.1542274732244 55.5772503545236,11.1542274732244 55.5772863545236,11.1541914732244 55.5772863545236,11.1541914732244 55.5772503545236))";55<br>
"POLYGON((11.1542274732244 55.5772503545236,11.1542634732244 55.5772503545236,11.1542634732244 55.5772863545236,11.1542274732244 55.5772863545236,11.1542274732244 55.5772503545236))";64<br>"POLYGON((11.1542634732244 55.5772503545236,11.1542994732244 55.5772503545236,11.1542994732244 55.5772863545236,11.1542634732244 55.5772863545236,11.1542634732244 55.5772503545236))";73<br>
<br><br><div class="gmail_quote">On Thu, Mar 22, 2012 at 2:58 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">
sure. Did you mean ST_GeomfromText or show it as text? <br><br>SELECT ST_GeomfromText ((gvxy).geom), ((gvxy).x - 1) * rwidth + (gvxy).y gridid<div class="im"><br>FROM (SELECT ST_PixelAsPolygons(rast) gvxy, ST_Width(rast) rwidth<br>
FROM (SELECT ST_AsRaster(ST_Extent(way_geom)::geometry, 0.000036, 0.000036) rast<br>
FROM buffers<br></div> where osm_id = 94695311<br> ) foo1<br> ) foo2;<br><br>ERROR: parse error - invalid geometry<br>HINT: "010300000001000000050000005" <-- parse error at position 27 within geometry<br>
<br>********** Error **********<br><br>ERROR: parse error - invalid geometry<br>SQL state: XX000<br>Hint: "010300000001000000050000005" <-- parse error at position 27 within geometry<div class="HOEnZb"><div class="h5">
<br><br><br><div class="gmail_quote">
On Thu, Mar 22, 2012 at 2:53 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">
I guess this is related to a GDAL problem where you cannot create a raster using ST_AsRaster with pixel size smaller than 1. Was this fixed Bborie?<br>
<br>
Ed could you reduce the list of geometries passed to ST_Extent to one and write it as ST_GeomfromText so we can debug this more easily?<br>
<div><br>
Pierre<br>
<br>
> -----Original Message-----<br>
> From: <a href="mailto:manohar.kaul@gmail.com" target="_blank">manohar.kaul@gmail.com</a> [mailto:<a href="mailto:manohar.kaul@gmail.com" target="_blank">manohar.kaul@gmail.com</a>] On Behalf<br>
> Of Ed Linde<br>
</div><div>> Sent: Thursday, March 22, 2012 9:45 AM<br>
> To: Pierre Racine<br>
> Cc: PostGIS Users Discussion<br>
> Subject: Re: [postgis-users] ST_Buffer + grid problem<br>
><br>
> Hi Pierre,<br>
</div><div><div>> So I am trying to have a 4meter by 4meter cell and I converted 4meters to<br>
> degrees, because I think ST_Extent will compute it in degrees as my geometry is<br>
> in srid 4326. But I get this GDAL error which I have no clue what it means. Any<br>
> ideas how I can fix it? Also I noticed that if I set it to 1.0, 1.0 I get<br>
> 21 rows but the gridid isn't continuous either (which is weird).<br>
><br>
> CREATE TABLE vectorgrid AS<br>
> SELECT (gvxy).geom, ((gvxy).x - 1) * rwidth + (gvxy).y gridid FROM (SELECT<br>
> ST_PixelAsPolygons(rast) gvxy, ST_Width(rast) rwidth<br>
> FROM (SELECT ST_AsRaster(ST_Extent(way_geom)::geometry, 0.000036,<br>
> 0.000036) rast<br>
> FROM buffers<br>
> ) foo1<br>
> ) foo2;<br>
><br>
> ERROR: rt_raster_gdal_rasterize: Unable to add band to GDALDataset<br>
><br>
> ********** Error **********<br>
><br>
> ERROR: rt_raster_gdal_rasterize: Unable to add band to GDALDataset SQL state:<br>
> XX000<br>
><br>
><br>
><br>
><br>
> On Thu, Mar 22, 2012 at 2:13 PM, Pierre Racine <<a href="mailto:Pierre.Racine@sbf.ulaval.ca" target="_blank">Pierre.Racine@sbf.ulaval.ca</a>><br>
> wrote:<br>
><br>
><br>
> You can control how the grid is aligned by using more ST_AsRaster<br>
> parameters. See:<br>
><br>
> <a href="http://postgis.refractions.net/documentation/manual-" target="_blank">http://postgis.refractions.net/documentation/manual-</a><br>
> svn/RT_ST_AsRaster.html<br>
><br>
> If you want it to align on your point, just align it on your points...<br>
><br>
> Pierre<br>
><br>
><br>
> > -----Original Message-----<br>
> > From: <a href="mailto:manohar.kaul@gmail.com" target="_blank">manohar.kaul@gmail.com</a> [mailto:<a href="mailto:manohar.kaul@gmail.com" target="_blank">manohar.kaul@gmail.com</a>]<br>
> On Behalf<br>
> > Of Ed Linde<br>
> > Sent: Thursday, March 22, 2012 9:05 AM<br>
> > To: PostGIS Users Discussion<br>
> > Cc: Pierre Racine<br>
> > Subject: Re: [postgis-users] ST_Buffer + grid problem<br>
> ><br>
> > Hi Pierre,<br>
> > Thanks for the grid idea last night. I have a problem though, I want to<br>
> have a 4m<br>
> > by 4m cell sized grid over my buffer geometries which are in SRID =<br>
> 4326. And<br>
> > then I have another data set of 2D points which are also in SRID<br>
> 4326...<br>
> > wondering how I can figure out from just a given (lat,long) which cell<br>
> ID in the<br>
> > buffer grid it would belong to? I am thinking that I might run into<br>
> "alignment<br>
> > issues" because shouldn't the extent of the grid be exactly the same<br>
> on the 2D<br>
> > point cloud as well, so that the grid cell IDs will match? Unless I am<br>
> missing<br>
> > something here?<br>
> ><br>
> > Cheers,<br>
> > Ed<br>
> ><br>
> ><br>
> ><br>
> > On Wed, Mar 21, 2012 at 8:46 PM, Pierre Racine<br>
> <<a href="mailto:Pierre.Racine@sbf.ulaval.ca" target="_blank">Pierre.Racine@sbf.ulaval.ca</a>><br>
> > wrote:<br>
> ><br>
> ><br>
> > > I am not sure if this is possible, but I have computed (using<br>
> ST_Buffer)<br>
> > a sort of<br>
> > > buffer around several LINESTRINGs. Now I would like to lay some<br>
> sort<br>
> > of grid of<br>
> > > say 1m^2 cell size on top of this collection of geometries and<br>
> then<br>
> > compute the<br>
> > > intersection... so in the end I would like to for example, know<br>
> that grid<br>
> > cell ID = 1<br>
> > > intersects with buffers 1 and 10, grid cell 2 intersects with buffers<br>
> 7, 10<br>
> > etc..<br>
> > ><br>
> > > Is there a simple way of doing this in postgis? Maybe someone<br>
> could<br>
> > point me to<br>
> > > some documentation of how I can generate such a grid in postgis<br>
> and<br>
> > maybe<br>
> > > then I can use just ST_Intersect once I have these two<br>
> geometries?<br>
> ><br>
> ><br>
> > With the raster type you can now easily create a vector grid like<br>
> 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)<br>
> rwidth<br>
> > FROM (SELECT ST_AsRaster(ST_Extent(geom)::geometry,<br>
> 1.0,<br>
> > 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<br>
> USING<br>
> > gist (geom);<br>
> > CREATE INDEX vectorgrid _geom_idx ON vectorgrid USING gist<br>
> > (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)<br>
> 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>
> ><br>
> ><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br>
</div></div></blockquote></div><br>