0

I cannot succeed to upload an out db cloud raster from AWS to a PostGIS db using raster2pgsql. I'm working on Windows 10, using PowerShell. I've set the appropriate environment variables and I can read raster information using gdalinfo, but when I try raster2pgsql I just get the response: ERROR: Unable to read raster file: /vsis3/....

What could the problem be?

As a reference I've used https://www.postgis.net/docs/manual-dev/RT_ST_GDALOpenOptions.html

Here is an example of my code:

PS C:\Users\Anton> $ENV:AWS_ACCESS_KEY_ID = '<my access key>'
PS C:\Users\Anton> $ENV:AWS_SECRET_ACCESS_KEY='<my secret key>'
PS C:\Users\Anton> $ENV:AWS_REGION='eu-north-1'
PS C:\Users\Anton> gdalinfo /vsis3/<my_bucket>/<my_raster_file.tif>
Driver: GTiff/GeoTIFF
<Correct raster information...>
PS C:\Users\Anton> & "C:\Program Files\PostgreSQL\13\bin\raster2pgsql.exe" -s 3006 -t 100x100 -p -I -R  /vsis3/<my_bucket>/<my_raster_file.tif> 'antons_schema.raster'
ERROR: Unable to read raster file: /vsis3/<my_bucket>/<my_raster_file.tif>

Update
After struggling with this for a few days I’ve now made a workaround. I installed VirtualBox and made a virtual Ubuntu machine. In there I installed all the necessary programs for PostGIS and connected to my database on my Windows host. By doing so I could run raster2pgsql and insert my out db cloud raster from AWS, using \vsis3\.

2
  • Could you have a try if raster2pgsql supports GDAL virtual file systems gdal.org/user/virtual_file_systems.html at all by trying to read for example a zipped GeoTIFF with /vsizip/? I am also not sure if raster2pgsql is using the system GDAL or if it has an own copy that is compiled with different options, for example without curl that is needed for accessing vsis3.
    – user30184
    Commented Nov 12, 2021 at 6:52
  • Thanks for the response! I hadn’t tried that, but yes. I can get raster2pgsql to read a zipped raster with /vsizip/. Commented Nov 14, 2021 at 8:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.