[postgis-devel] ST_SetValues (Generating raster from point data)

David Haynes II dahaynes at umn.edu
Wed Nov 12 12:46:55 PST 2014


Sorry, I don't think the link that you sent has the rc_Patch2Raster_arar
function.
This is my current stumbling block

On Tue, Oct 28, 2014 at 12:37 PM, Rémi Cura <remi.cura at gmail.com> wrote:

> Hey,
> I wrote some code for this
> Check :
> https://github.com/Remi-C/Postgres_Day_2014_10_RemiC/blob/master/Point_Cloud/Patch_to_raster/patch_to_raster.sql
>
> I do a little more because I convert a pcpatch,
> but you could take the part that takes a table of attributes (X,Y,Z,
> whatever) and convert it to a raster.
>
> ST_Setvalues is the fastest way  I found,
>  but it is still *very *slow
> I would advice to do this outside db or with efficient python/C code.
> (for instance python-gdal ?)
>
> Cheers,
> Rémi
>
> 2014-10-28 18:04 GMT+01:00 David Haynes II <dahaynes at umn.edu>:
>
>> Hello,
>>
>> 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.
>> The ST_SetValues does not work as I have currently implemented. Because
>> each time a value is assigned it generates another raster.
>> 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.
>>
>> 1. Convert text to geometry value
>> 2. Determine raster extent using convexhull.
>> 3. Generate raster using ST_AsRaster
>> 4. Set raster cell values using ST_SetValues
>>
>> with noaa_raster as
>> (
>> select ST_AsRaster(p_bound.geom, 3.75::float8, 2.5::float8, '32BF', 1, 0)
>> as rast
>>  from (
>>   --Generate polygon extent from all points
>>   SELECT st_convexhull(ST_Collect(base.geom)) as geom
>>   FROM (
>>   --Converts text to geometry
>>   select p.grid_id, ST_geomfromtext('POINT(' || p.longitude || ' ' ||
>> p.latitude || ')',4326) as geom, p.value
>>   from noaa p
>>   ) base
>>   ) p_bound
>> )
>> --distances are changed to make sure we fine the centroid of each raster
>> cell
>> 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
>> from noaa p, noaa_raster r
>>
>>
>> see
>> http://postgis.net/docs/manual-dev/RT_ST_SetValues.html
>>
>> --
>> David Haynes, Ph.D.
>> Research Associate Terra Populus
>> Minnesota Population Center
>> www.terrapop.org
>>
>> _______________________________________________
>> postgis-devel mailing list
>> postgis-devel at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel
>>
>
>
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel
>



-- 
David Haynes, Ph.D.
Research Associate Terra Populus
Minnesota Population Center
www.terrapop.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20141112/25614167/attachment.html>


More information about the postgis-devel mailing list