I tried a few roads at random and it doesn't reproduce that error, though I am a bit suspicious about the actual <div>query. This part in particular</div><div><br></div><div>(SELECT ST_AsRaster(ST_Extent(way_geom)::geometry, 0.000036,<br>
> 0.000036) rast<br>>                          FROM buffers<br>>                         ) foo1</div><div><br></div><div>Are we saying that we want to compute the extent of each and every geometry in my table? Or should we not </div>
<div>be getting the maximum extents for ALL the geometries? </div><div>So when I say something like "FROM buffers where osm_id in (... list of 10 IDs)... " this query runs forever!</div><div>Eventhough checking them one by one returns with results immediately.</div>
<div>So I am not entirely sure how to do this or how I can reproduce this bug to help you guys. </div><div>Any suggestions?</div><div><br><br><div class="gmail_quote">On Thu, Mar 22, 2012 at 3:23 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">Yeah only problem being that I don't know which geometry is the one that fails... its a table with 300K geometries. <div>
Have never written any PgSQL, so this I guess would require a loop to check which OSM ID its failing on. Unless</div>
<div>you got a good idea to pin-point this error?<div><div class="h5"><br><br><div class="gmail_quote">On Thu, Mar 22, 2012 at 3:16 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">What I mean is to replace:<br>
<div><br>
SELECT ST_AsRaster(ST_Extent(way_geom)::geometry, 0.000036, 0.000036) rast FROM buffers  where osm_id = 94695311<br>
<br>
</div>by something like:<br>
<br>
SELECT ST_AsRaster(ST_GeomFromText('POLYGON((11.1539754732244 55.5772503545236,11.1540114732244 55.5772503545236,11.1540114732244 55.5772863545236,11.1539754732244 55.5772863545236,11.1539754732244 55.5772503545236))'), 0.000036, 0.000036)<br>


<br>
with one of the geometry reproducing the bug so we don't need your dataset to test and reproduce.<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:59 AM<br>
> To: Pierre Racine<br>
</div><div><div>> Cc: PostGIS Users Discussion; Bborie Park (<a href="mailto:bkpark@ucdavis.edu" target="_blank">bkpark@ucdavis.edu</a>)<br>
> Subject: Re: [postgis-users] ST_Buffer + grid problem<br>
><br>
> 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<br>
> FROM (SELECT 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>
>                          where osm_id = 94695311<br>
>                         ) foo1<br>
>            ) foo2;<br>
><br>
> ERROR:  parse error - invalid geometry<br>
> HINT:  "010300000001000000050000005" <-- parse error at position 27 within<br>
> geometry<br>
><br>
> ********** Error **********<br>
><br>
> ERROR: parse error - invalid geometry<br>
> SQL state: XX000<br>
> Hint: "010300000001000000050000005" <-- parse error at position 27 within<br>
> geometry<br>
><br>
><br>
><br>
> On Thu, Mar 22, 2012 at 2:53 PM, Pierre Racine <<a href="mailto:Pierre.Racine@sbf.ulaval.ca" target="_blank">Pierre.Racine@sbf.ulaval.ca</a>><br>
> wrote:<br>
><br>
><br>
>       I guess this is related to a GDAL problem where you cannot create a<br>
> 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<br>
> and write it as ST_GeomfromText so we can debug this more easily?<br>
><br>
><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>]<br>
> On Behalf<br>
>       > Of Ed Linde<br>
><br>
>       > 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>
><br>
>       > So I am trying to have a 4meter by 4meter cell and I converted<br>
> 4meters to<br>
>       > degrees, because I think ST_Extent will compute it in degrees as my<br>
> geometry is<br>
>       > in srid 4326. But I get this GDAL error which I have no clue what it<br>
> 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<br>
> (SELECT<br>
>       > ST_PixelAsPolygons(rast) gvxy, ST_Width(rast) rwidth<br>
>       >             FROM (SELECT ST_AsRaster(ST_Extent(way_geom)::geometry,<br>
> 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<br>
> SQL state:<br>
>       > XX000<br>
>       ><br>
>       ><br>
>       ><br>
>       ><br>
>       > On Thu, Mar 22, 2012 at 2:13 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>
>       >       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><br>
> [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<br>
> want to<br>
>       > have a 4m<br>
>       >       > by 4m cell sized grid over my buffer geometries which are in SRID<br>
> =<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<br>
> 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<br>
> same<br>
>       > on the 2D<br>
>       >       > point cloud as well, so that the grid cell IDs will match? Unless I<br>
> 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<br>
> some<br>
>       > sort<br>
>       >       > of grid of<br>
>       >       >       > say 1m^2 cell size on top of this collection of geometries<br>
> and<br>
>       > then<br>
>       >       > compute the<br>
>       >       >       > intersection... so in the end I would like to for example,<br>
> know<br>
>       > that grid<br>
>       >       > cell ID = 1<br>
>       >       >       > intersects with buffers 1 and 10, grid cell 2 intersects with<br>
> buffers<br>
>       > 7, 10<br>
>       >       > etc..<br>
>       >       >       ><br>
>       >       >       > Is there a simple way of doing this in postgis? Maybe<br>
> someone<br>
>       > could<br>
>       >       > point me to<br>
>       >       >       > some documentation of how I can generate such a grid in<br>
> 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<br>
> 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<br>
> 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<br>
> yourbuffertable<br>
>       > USING<br>
>       >       > gist  (geom);<br>
>       >       >       CREATE INDEX vectorgrid _geom_idx  ON vectorgrid USING<br>
> 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>
><br>
><br>
<br>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>