<div dir="ltr"><div><div><div>Sorry,<br></div>I messed up between projects.<br></div>Here is the correct file:<br><a href="https://github.com/Remi-C/Postgres_Day_2014_10_RemiC/blob/master/Point_Cloud/Patch_to_raster/patch_to_raster_all_pixels.sql">https://github.com/Remi-C/Postgres_Day_2014_10_RemiC/blob/master/Point_Cloud/Patch_to_raster/patch_to_raster_all_pixels.sql</a><br><br></div>Cheers,<br>Rémi<br></div><div class="gmail_extra"><br><div class="gmail_quote">2014-11-12 21:46 GMT+01:00 David Haynes II <span dir="ltr"><<a href="mailto:dahaynes@umn.edu" target="_blank">dahaynes@umn.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font face="arial, helvetica, sans-serif">Sorry, I don't think the link that you sent has the <span style="color:rgb(51,51,51);font-size:12px;line-height:16.7999992370605px;white-space:pre-wrap">rc_Patch2Raster_arar function.</span></font><div><span style="color:rgb(51,51,51);line-height:16.7999992370605px;white-space:pre-wrap"><font face="arial, helvetica, sans-serif">This is my current stumbling block</font></span></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 28, 2014 at 12:37 PM, Rémi Cura <span dir="ltr"><<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hey,<br></div>I wrote some code for this <br>Check :<a href="https://github.com/Remi-C/Postgres_Day_2014_10_RemiC/blob/master/Point_Cloud/Patch_to_raster/patch_to_raster.sql" target="_blank">https://github.com/Remi-C/Postgres_Day_2014_10_RemiC/blob/master/Point_Cloud/Patch_to_raster/patch_to_raster.sql</a><br><br></div><div>I do a little more because I convert a pcpatch, <br>but you could take the part that takes a table of attributes (X,Y,Z, whatever) and convert it to a raster. <br></div><div><br></div>ST_Setvalues is the fastest way  I found,<br></div> but it is still <b>very </b>slow<br></div>I would advice to do this outside db or with efficient python/C code.<br></div>(for instance python-gdal ?)<br><div><div><div><br>Cheers,<br>Rémi<br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2014-10-28 18:04 GMT+01:00 David Haynes II <span dir="ltr"><<a href="mailto:dahaynes@umn.edu" target="_blank">dahaynes@umn.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I am hoping someone can help point me in the correct direction on this problem. I am trying to take a table of point data and generate a raster, using some NOAA data. These are the steps that I have taken so far. Everything is fine until step 4.</div><div>The ST_SetValues does not work as I have currently implemented. Because each time a value is assigned it generates another raster.</div><div>The examples I have seen using ST_SetValues require each recordset to be appended to each other. Does anyone have any knowledge about other psql functions that will allow me to transpose the recordset or append recordsets together. I am considering writing a custom function to do the task.</div><div><br></div><div>1. Convert text to geometry value</div><div>2. Determine raster extent using convexhull.</div><div>3. Generate raster using ST_AsRaster</div><div>4. Set raster cell values using ST_SetValues<br clear="all"><div><br></div><div>with noaa_raster as</div><div>(</div><div><div>select ST_AsRaster(p_bound.geom, 3.75::float8, 2.5::float8, '32BF', 1, 0) as rast</div><div> from<span style="white-space:pre-wrap">  </span>(</div><div> <span style="white-space:pre-wrap">      </span>--Generate polygon extent from all points</div><div> <span style="white-space:pre-wrap">      </span>SELECT st_convexhull(ST_Collect(base.geom)) as geom</div><div> <span style="white-space:pre-wrap">    </span>FROM<span style="white-space:pre-wrap">    </span>(</div><div> <span style="white-space:pre-wrap">              </span>--Converts text to geometry</div><div> <span style="white-space:pre-wrap">            </span>select p.grid_id, ST_geomfromtext('POINT(' || p.longitude || ' ' || p.latitude || ')',4326) as geom, p.value</div><div> <span style="white-space:pre-wrap">           </span>from noaa p</div><div> <span style="white-space:pre-wrap">            </span>) base</div><div> <span style="white-space:pre-wrap"> </span>) p_bound</div></div><div>)</div><div>--distances are changed to make sure we fine the centroid of each raster cell</div><div><div>select r.rid, p.grid_id, ST_SetValues(r.rast, 1, ARRAY[ROW(ST_geomfromtext('POINT(' || p.longitude + 1.875 || ' ' || p.latitude - 1.25 || ')',4326), p.value)]::geomval[], True ) as rast</div><div>from noaa p, noaa_raster r</div></div><div><br></div><div><br></div><div>see</div><div><a href="http://postgis.net/docs/manual-dev/RT_ST_SetValues.html" target="_blank">http://postgis.net/docs/manual-dev/RT_ST_SetValues.html</a><span><font color="#888888"><span><font color="#888888"><br></font></span></font></span></div><span><font color="#888888"><span><font color="#888888"><div><br></div>-- </font></span></font></span></div><span><font color="#888888"><span><font color="#888888"><div><div dir="ltr">David Haynes, Ph.D.<div>Research Associate Terra Populus</div><div>Minnesota Population Center</div><div><a href="http://www.terrapop.org" target="_blank">www.terrapop.org</a></div></div>
</div></font></span></font></span></div><span><font color="#888888">
<br>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br></font></span></blockquote></div><br></div>
<br>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">David Haynes, Ph.D.<div>Research Associate Terra Populus</div><div>Minnesota Population Center</div><div><a href="http://www.terrapop.org" target="_blank">www.terrapop.org</a></div></div></div>
</div>
</div></div><br>_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br></blockquote></div><br></div>