0

I used the following command to import a bunch of raster to postgis out-db style (only pointers to the rasters are stored in the database):

raster2pgsql -s {srid} -c -R -I -C -F -t auto {file_name} public.{table} | psql -h {host} -p {port} -d {database} -U {user} --no-password

Now I want to rename all those files that I previously imported. I already renamed them on the filesystem. Now when I try to retrieve them I get:

psycopg2.InternalError: rt_band_load_offline_data: Cannot open offline raster: /myfilepath/file_name.tif

Where in the Postgis db to I rename the files (edit the pointer path) so that I can access them again? I'm hoping I can do this without re-importing everything again using raster2psgsql.

1

It is a bit of a hassle and I've never done it myself, but you would have to create a new band for said raster.

Something like:

UPDATE myrasters SET rast = ST_AddBand(
        rast,
        '/home/raster/myraster1.tif'::text, NULL::int[]
    )

Make sure you get the right metadata first from the existing raster band and adapt your path for every file by concatenating or regexing it to the desired new filename.

Also check: http://postgis.net/docs/manual-2.2/RT_ST_AddBand.html

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.