[postgis-users] Rasterize a vector

Paolo Cavallini cavallini at faunalia.it
Tue May 29 11:20:59 PDT 2012


Il 29/05/2012 20:06, Bborie Park ha scritto:

> WITH ref AS (
> 	SELECT ST_MakeEmptyRaster(1, 1, 0, 0, 1, -1, 0, 0, 0) AS rast
> )
> SELECT
> 	ST_AsRaster(g.geom, ref.rast, '32BUI', g.id, 0)
> FROM mygeomtable g
> CROSS JOIN ref
> 
> That would convert your geometries into rasters, all of which have the
> same alignment with pixel values set to the particular geometry's id.
> So, for 20 input geometries, there would be 20 output rasters.

but:

WITH ref AS (
SELECT ST_MakeEmptyRaster(1, 1, 0, 0, 1, -1, 0, 0, 3003) AS rast
)
SELECT
ST_AsRaster(g.geom, ref.rast, '32BUI', g.id, 0)
FROM province g
CROSS JOIN ref;
ERROR:  rt_raster_gdal_rasterize: Unable to add band to GDALDataset
CONTEXT: PL/pgSQL function "st_asraster" line 26 at RETURN

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



More information about the postgis-users mailing list