Search code examples
postgresqlpostgisraster

Unable to import raster data to postgis


I have been trying to import my SRTM raster data into my postgis using the command, but has generated the following error (tried multiple times). Is there any thing missing? I appreciate for any help

Error message:

ERROR: relation "test" already exists
ERROR: current transaction is aborted, commands ignored until end of transaction block

enter image description here


Solution

  • Welcome to SO.

    The error message says you're trying to create a relation that already exists. Either drop it in your database ..

    DROP TABLE test;
    

    .. or tell raster2pgsql to do it for your by adding the parameter -d to your command.

    -d Drops the table, then recreates it and populates

    Something like

    raster2pgsql -I -z 10x10 -C -F -s 4326 file.hgt -d public.test | psql ...
    

    An alterative is to use -a to append the data to an existing table

    -a Appends raster into current table, must be exactly the same table schema.