[postgis-users] Rasterize a vector

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Tue May 29 11:05:05 PDT 2012


> 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.

There should not be N tiles. Just N rasters...

The most important is: At the end do you want all geometries to be burned into the same raster or you want one raster per geometries?

Pierre




More information about the postgis-users mailing list