Copying Rasters in PostGIS

I ran into a process where I wanted to create copies of rasters in PostgreSQL. While seemingly a simple process this took me a bit of work to figure out.

For my workflow I had three rasters, which all have the same size, and I want to load them into the same PostGIS table with three raster geometry columns. I don’t think this will work for different sized rasters since the rid’s will not match.

Three rasters:

Which I want to copy into:

First to create the merged raster table:

Then to add the rid’s. These are the id’s of the tiles that the raster was split into when loading. If your tile size is large enough then you may only have one.

Then copying the actual data is straighforward (this assumes the raster column in the raster1 datasets is called rast):

Now I still have an issue that QGIS will not load these layers. It will always load the initial raster column no matter what is chosen.

Leave a Reply

Your email address will not be published. Required fields are marked *