[postgis-users] Rasterize a vector

Paolo Cavallini cavallini at faunalia.it
Tue May 29 10:56:10 PDT 2012


Il 29/05/2012 19:03, Bborie Park ha scritto:
> Read it again.  The very first variant listed on that page has the
> ST_AsRaster(geom geometry, rast raster, ...)

Yes, that's what I was trying, without success. Let's say I have two adjacent
polygons, and I want a raster where the cells have the value of one of the fields of
the the polygons (say, the id). Moreover, I want the resulting raster to be aligned
to an existing raster (this is a very common task in GIS, easily done in GRASS, GDAL,
SAGA, etc.). I do not see an option in:

ST_AsRaster(geometry geom, raster ref, text pixeltype, double precision value=1,
double precision nodataval=0, boolean touched=false);

to write in each cell the value of the raster. Moreover, a simple

 CREATE TABLE rasterized as
   select b.rid, ST_AsRaster(a.geom, b.rast, '4BUI') as rast
   from province a, hdr b;

results in (N geometries * N tiles) records, whereas I needed (N tiles) records, and
for each tile a raster with a different value for each province.

All the best, and thanks.
-- 
Paolo Cavallini - Faunalia
www.faunalia.eu
Full contact details at www.faunalia.eu/pc



More information about the postgis-users mailing list