0

I am trying to load all the SRTM data into a PostGIS database. I tried the process described here: https://postgis.net/docs/using_raster_dataman.html It created a giant SQL file. When I tried loading this file, the process used up all my machine's memory and crashed without loading anything.

How can I load all the SRTM data into a single PostGIS table?

Edit: Here is the command I used to create the SQL file:

raster2pgsql -c *.hgt srtm > srtm.sql

And then I loaded it with:
psql -d public -f srtm.sql

Edit: Here is the error I got:
...(many occurrences of the insert messages)...
INSERT 0 1
psql:srtm.sql:8520: ERROR: invalid byte sequence for encoding "UTF8": 0xd2 0xd2
psql:srtm.sql:8577: invalid command \
psql:srtm.sql:8604: invalid command \
psql:srtm.sql:9043: out of memory

  • I doubt a set of large files filled up memory, just disk storage. After generating the SQL, you're supposed to load it into the database, then archive or delete. – Vince Feb 11 at 14:34
  • @Vince There is more than enough disk space. – Craeft Feb 11 at 14:42
0

You should try to use raster2pgsql instead of generating huge text files. On the tiff version (it should work with the other version too), I used it like that:

CREATE SCHEMA mnt;
raster2pgsql -d -C -I -M -t 200x200 -l 2,4,8 /data/*.tif public.mnt | PGPASSWORD=pass psql -h localhost -U your_user-w -d your_base

The -l 2,4,8 is to create different aggregates to simplify the visualization in low level zoom, you can delete this part if you want. It worked for the whole world.

  • See my edit for the command I used to create the SQL file. – Craeft Feb 11 at 15:28
  • Yes, but I guess you should use it like I did to maybe avoid the problem (direct pipe instead of using a temporary sql file) – robin loche Feb 12 at 10:05

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.