Search code examples
postgresqlpostgisraster

raster2pgsql: "Could not allocate memory for INSERT statement"


I'm very new to raster2pgsql so please bear with me. I'm trying to load a 60mb .tif (from the High-Resolution Settlements Layer project) to my postgis-enabled database with the following code:

raster2pgsql -s 5235 -C -F [path to the .tif] public.hrsl_lka | psql -h localhost -U postgres -p 5432 -d project

However, I get the following error:

ERROR: insert_records: Could not allocate memory for INSERT statement ERROR: process_rasters: Could not convert raster tiles into INSERT or COPY statements ERROR: Unable to process rasters

Loading smaller .tifs of around 3mb to the same database but from other sources works fine, however.

Is there a size limit with raster2pgsql? I'm on PostgreSQL 12.4.

With many thanks, Gregor


Solution

  • Have you tried setting the tile size -t?

    According to the documentation:

    -t: Tile size - expressed as width x height. If not provided, a default is worked out automatically in the range of 32-100 so it best matches the raster dimensions. It is worth remembering that when importing multiple files, tiles will be computed for the first raster and then applied to others.

    Alternatively you can let the script compute it for you by means of setting -t to auto e.g.

    raster2pgsql -s 5235 -t auto -C -F file.tif public.hrsl_lka | psql -d db
    

    Related answer: Are there limitations using a PostGIS out-db raster?