<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 class="" style="white-space:pre">      </span>(</div><div> <span class="" style="white-space:pre">        </span>--Generate polygon extent from all points</div><div> <span class="" style="white-space:pre">        </span>SELECT st_convexhull(ST_Collect(base.geom)) as geom</div><div> <span class="" style="white-space:pre">      </span>FROM<span class="" style="white-space:pre">      </span>(</div><div> <span class="" style="white-space:pre">                </span>--Converts text to geometry</div><div> <span class="" style="white-space:pre">              </span>select p.grid_id, ST_geomfromtext('POINT(' || p.longitude || ' ' || p.latitude || ')',4326) as geom, p.value</div><div> <span class="" style="white-space:pre">             </span>from noaa p</div><div> <span class="" style="white-space:pre">              </span>) base</div><div> <span class="" style="white-space:pre">   </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">http://postgis.net/docs/manual-dev/RT_ST_SetValues.html</a><br></div><div><br></div>-- </div><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>