Hi Mark,

Can you elaborate on what you mean by "resultant raster does not map to
the reference raster"?

The output from ST_AsRaster should result in a raster with the same
SRID, scale and skew as the reference raster.  The output raster should
also be aligned with the reference raster as tested by ST_SameAlignment.

-bborie

On 06/23/2012 11:04 PM, Mark Wynter wrote:
> I can rasterise a vector layer, but I'm having trouble mapping it to a 
> reference raster.
> 
> The reference raster, called dummy_rast is a 1x1 raster tile with a height 
> and width of 500pixels, each of 250m in size.  I created using a pl/pgsql 
> function:
> SELECT make_tiled_raster('public', 'dummy_rast', 576000, -3780000, 1, 1, 500, 
> 500, 250, -250);
> The result is 
>  
>  srid | scale_x | scale_y | blocksize_x | blocksize_y | num_bands | 
> pixel_types | nodata_values 
> ------+---------+---------+-------------+-------------+-----------+-------------+---------------
>  3577 |     250 |    -250 |         500 |         500 |         1 | {8BUI}    
>   | {NULL}
> 
> 
> I now wish to burn a vector layer onto this raster:
> 
> CREATE TABLE viewshed_rast AS
> WITH vt as (SELECT ST_Union(geometry) as geometry FROM viewshed_vectors)
> SELECT rt.rid, ST_AsRaster(vt.geometry, rt.rast, '8BUI', 120, 100) as rast 
> FROM dummy_rast as rt, vt;
> 
> The result is 
> srid | scale_x | scale_y | blocksize_x | blocksize_y | num_bands | 
> pixel_types | nodata_values 
> ------+---------+---------+-------------+-------------+-----------+-------------+---------------
>  3577 |     250 |    -250 |          67 |          38 |         1 | {8BUI}    
>   | {100}
> (1 row)
> 
> I do not understand why the resultant raster does not map to the reference 
> raster?   Refer screenshot attached showing the resultant layers in QGIS.  
> The upperleftx and upperlefty, and the block size of the resultant raster are 
> defined by the extent of the vector layer and not the reference raster.   
> 
> Is there something obvious I'm doing wrong?  Thanks.
> 
> 
> 
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

-- 
Bborie Park
Programmer
Center for Vectorborne Diseases
UC Davis
530-752-8380
bkp...@ucdavis.edu
_______________________________________________
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to