Database Reference
In-Depth Information
CREATE INDEX uas_voronoi_count_the_geom_gist
ON chp07.uas_voronoi_count
USING gist
(the_geom );
Now, we can construct our Voronoi polygons with the colors from the point cloud
joined to the polygons themselves.
DROP TABLE IF EXISTS chp07.uas_voronoi_join;
CREATE TABLE chp07.uas_voronoi_join AS
SELECT uv.gid, uv.the_geom, red, green, blue
FROM chp07.uas_voronoi_count uv
LEFT JOIN chp07.uas_subset uas
ON ST_Intersects(uv.the_geom, uas.the_geom);
Rendering polygons to raster
The final step in our processing chain is to convert our Voronoi polygons to raster.
ST_AsRaster willconvertourgeometrytoraster.Todoso,wefirstneedtocreate
adummyrasterwiththesizeandtypeofourfinalraster. ST_AsRaster takesafew
inputs, depending on the use case. In our case:
ST_AsRaster(ST_Union(the_geom), 100, 100,
ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[0,0,0],
ARRAY[0,0,0])
So,forourinputs,wehaveourgeometry,width,height,andthreearraysspecifying
pixeltype,inputpixelvalue,andbackgroundpixelvalue.Forourremainingarrays,
wepopulatethemwithzerosforbackgroundvalues.But,first,weshouldmodifyour
functionabittoensurethatwemaintainsquarepixelsinouroutputraster.Todoso,
we will calculate the ratio of width to height in the input geometry envelope. For a
100-pixel image, this would look something like this:
SELECT round(100 * (
(ST_XMax(ST_Collect(the_geom)) -
ST_XMin(ST_Collect(the_geom))) /
Search WWH ::




Custom Search