Database Reference
In-Depth Information
The ST_PixelsAsPolygons() function returns one geometry for each pixel. If
there are 100 pixels, there will be 100 geometries. Each geometry of
ST_DumpAsPolygons() is the union of all of the pixels in an area with the same
value. If there are 100 pixels, there may be up to 100 geometries.
There is one other significant difference between ST_PixelAsPolygons() and
ST_DumpAsPolygons() . Unlike ST_DumpAsPolygons() ,
ST_PixelAsPolygons() returnsageometryforpixelswiththe NODATA valueand
has an "empty" value for the val column.
Let's convert a geometry to a raster with ST_AsRaster() . We insert
ST_AsRaster() toreturnarasterwithapixelsizeof100by-100metersandone
thatcontainsfourbandsofthepixeltype 8BUI .Eachofthesebandswillhaveapixel
NODATA valueof 0 andaspecificpixelvalue(29,194,178,and255foreachband
respectively). The units for pixel size are determined by the geometry's projection,
which is also the projection of the created raster.
SELECT
ST_AsRaster(
sf.geom,
100., -100.,
ARRAY['8BUI', '8BUI', '8BUI',
'8BUI']::text[],
ARRAY[29, 194, 178,
255]::double precision[],
ARRAY[0, 0, 0, 0]::double
precision[]
)
FROM sfpoly sf;
Search WWH ::




Custom Search