2

I have a raster table and a geometry table in postgis. My goal is to create a single raster merging elements from both:-

WITH geom_raster AS (

    SELECT wkb_geometry, ST_AsRaster(wkb_geometry, 200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]) as rast FROM geometry_table
),
raster AS (

    SELECT ST_Union(rast) from raster_table,geom_raster where wkb_geomtry && rast
)
   SELECT ............

What is the last step to merge the two into a single raster so I see the geometry on top of the raster? I tried ST_Union but get an error about alignment which I suspect means the grids or SRIDS or something else are not in unison?

2

Answer was staring me in the face after a more detailed read of documentation:-

SELECT ST_AsRaster(ST_Buffer(wkb_geometry, 50), 
                  rast,
                  ARRAY['8BUI'], 
                  ARRAY[118]
                  )         
          as rast FROM  raster,geometry_table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.