<div dir="ltr"><div><div><div><div>Hey,<br>the whole point on using a sgbds like postgis is using index.<br><br></div>If you have one line you don't use indexes...<br><br></div>So in short, don't make one polygon with a buffer of all the road, but a table with a line for the buffer for every road, then do you computation to create grid of points inside of polygons, then union the result of points!<br>
<br></div><div>And it s always a bad idea to run a function on big data when you have not tested it fully (including scaling behavior) on small data.<br><br><br></div>Cheers<br></div>Rémi-C<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/11/11 James David Smith <span dir="ltr"><<a href="mailto:james.david.smith@gmail.com" target="_blank">james.david.smith@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
Would appreciate some advice on the best way to accomplish this please.<br>
<br>
Our situation is that we have a single polygon which has been created<br>
by buffering all of the major roads in the UK. Projection is OSGB36<br>
(27700). Obviously it's quite a big polygon.<br>
<br>
-->  SELECT st_area(geom) FROM roadbufferunion;<br>
     st_area<br>
------------------<br>
 77228753220.8271<br>
<br>
What we now want to do is create a regular grid of 20 metre x 20 metre<br>
points instead the polygon area. So we wrote this function (based on<br>
some googling, apologies for not being able to recall the exact person<br>
who originally wrote it):<br>
<br>
CREATE OR REPLACE FUNCTION makegrid(geometry, integer, integer)<br>
RETURNS geometry AS<br>
'SELECT ST_Collect(st_setsrid(ST_POINT(x,y),$3)) FROM<br>
  generate_series(53320::int, 667380::int,$2) as x<br>
  ,generate_series(7780::int, 1226580::int,$2) as y<br>
where st_intersects($1,st_setsrid(ST_POINT(x,y),$3))'<br>
LANGUAGE sql<br>
<br>
and we then run this by doing the following:<br>
<br>
SELECT st_x((ST_Dump(makegrid(geom, 20, 27700))).geom) as x,<br>
st_y((ST_Dump(makegrid(geom, 20, 27700))).geom) as y INTO grid_points<br>
from roadbufferunion;<br>
<br>
However after over 2 days of the query running on a pretty powerful<br>
linux cluster, we still have no result.  I'm not sure if it is<br>
actually running or not to be honest.<br>
<br>
Does the query look right?<br>
Any ideas how we can make it run quicker?<br>
<br>
Thanks<br>
<br>
James<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
</blockquote></div><br></div>