Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open raster using rasterio and s3

I'm storing rasters in Amazon S3 bucket and would like to open specific object using installed rasterio library in my Django docker container.

AWS_ACCESS_KEY_ID and AWS_ACCESS_KEY_ID are incluced in docker-compose.yml env variables.

Inside docker container and trying:

$ python manage.py shell
$ import rasterio
$ with rasterio.open(url_to_s3_object) as file:
$ ....print(file)

I'm receiving error:

Traceback (most recent call last):
  File "rasterio/_base.pyx", line 72, in rasterio._base.DatasetReader.start (rasterio/_base.c:2847)
  File "rasterio/_base.pyx", line 74, in rasterio._base.DatasetReader.start (rasterio/_base.c:2799)
  File "rasterio/_err.pyx", line 196, in rasterio._err.CPLErrors.check (rasterio/_err.c:1773)
  rasterio._err.CPLE_OpenFailed: {URL TO S3 OBJECT} does not exist in the file system, and is not recognised as a supported dataset name.

What is the solution for that?

In local machine everything works fine.

like image 817
sorryMike Avatar asked Oct 22 '25 22:10

sorryMike


1 Answers

Found a solution for that. rasterio lib works correct with s3 under GDAL 2.1.0 at least - https://github.com/rasterio/rasterio/blob/master/docs/topics/vsi.rst#aws-s3 Upgrading GDAL solves the problem.

like image 145
sorryMike Avatar answered Oct 25 '25 13:10

sorryMike



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!