Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to write tiff in S3 failed #1189

Closed
lcluowb opened this issue Jan 9, 2019 · 1 comment

Comments

@lcluowb
Copy link

commented Jan 9, 2019

Expected behavior and actual behavior.

I expected to write a tiff image in S3 file system. I first read a tiff from S3 and get its Dataset Object, then I reprojected it and got the returned Dataset, but when I want to FlushCache it throw errors.
I do this work with java.

Steps to reproduce the problem.

// set config
gdal.AllRegister();
gdal.SetConfigOption("AWS_SECRET_ACCESS_KEY", sk);
gdal.SetConfigOption("AWS_ACCESS_KEY_ID", ak);
gdal.SetConfigOption("AWS_DEFAULT_REGION", region);
gdal.SetConfigOption("AWS_S3_ENDPOINT", endpoint);
// read image
Dataset srcDs = gdal.Open(path, gdalconst.GA_ReadOnly);
// calculate new image's geoTransform
...
// create dst Dataset, set geoTransform and projection
Driver driver = gdal.GetDriverByName("GTiff");
Dataset dstDs = driver.Create(outputPath, dstWidth, dstHeight, srcDs.getRasterCount(),
      srcDs.GetRasterBand(1).GetRasterDataType());
dstDs.SetGeoTransform(dstGeoTransform);
dstDs.SetProjection(dstPrj);
gdal.ReprojectImage(srcDs, dstDs, srcPrj, dstPrj, reasampleAlg);
// write image and release
dstDs.FlushCache();
dstDs.delete()

then it throw errors like this:

ERROR 6: Seek not supported on writable /vsis3/ files
ERROR 1: _tiffSeekProc:success
ERROR 1: _tiffWriteProc:success
ERROR 1: /vsis3/testworkspacebucket/testworkspaceprefix/proj.tif:Error writing TIFF header
ERROR 6: Read not supported on writable /vsis3/ files
ERROR 1: TIFFFetchDirectory:/vsis3/testworkspacebucket/testworkspaceprefix/proj.tif: Can not read TIFF directory count
ERROR 1: TIFFReadDirectory:Failed to read directory at offset 8
ERROR 1: _tiffWriteProc:success
ERROR 1: TIFFAppendToStrip:Write error at scanline 104
ERROR 1: _tiffWriteProc:success
ERROR 6: Seek not supported on writable /vsis3/ files
ERROR 1: _tiffSeekProc:success
ERROR 1: _tiffWriteProc:success
ERROR 1: /vsis3/testworkspacebucket/testworkspaceprefix/proj.tif:Error updating TIFF header
ERROR 6: Seek not supported on writable /vsis3/ files
ERROR 1: _tiffSeekProc:success
ERROR 1: TIFFFetchDirectory:/vsis3/testworkspacebucket/testworkspaceprefix/proj.tif: Seek error accessing TIFF directory
ERROR 1: TIFFReadDirectory:Failed to read directory at offset 60040
ERROR 6: Seek not supported on writable /vsis3/ files
ERROR 1: _tiffSeekProc:success
ERROR 1: TIFFRewriteDirectory:Error fetching directory count
ERROR 6: Seek not supported on writable /vsis3/ files
ERROR 1: _tiffSeekProc:success
ERROR 1: TIFFRewriteDirectory:Error fetching directory count

Operating system

CentOS 7

GDAL version and provenance

gdal-2.3.2 with jdk1.8

@rouault

This comment has been minimized.

Copy link
Member

commented Jan 9, 2019

Yes this is expected behaviour. TIFF writing requires random writing capabilities and /vsis3/ supports only sequential writing. Consequently you need to create a local copy before uploading it.

@rouault rouault closed this in 748e7f9 Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.