[gdal-dev] Writing geotiff with /vsigs in Python does not work

Christoph Paulik cpaulik at vandersat.com
Thu Jul 19 03:44:50 PDT 2018


Hi,

I'm running the following code writing a geotiff and I've set the
GOOGLE_APPLICATION_CREDENTIALS environment variable for authentication:

from osgeo import gdal, gdal_array, osr
import numpy as np

file_name = '/vsigs/<my-bucket-name>/test.tif'

raster = np.arange(100*100, dtype=np.int32).reshape((100, 100))
data_type = gdal_array.NumericTypeCodeToGDALTypeCode(raster.dtype)

cols = raster.shape[1]
rows = raster.shape[0]
driver = gdal.GetDriverByName("GTiff")
create_options=['COMPRESS=LZW', 'TILED=YES']

ds = driver.Create(file_name, cols, rows, 1, data_type, create_options)
# (top left x, w-e pixel resolution, rotation, top left y, rotation, n-s pixel resolution)
ds.SetGeoTransform((10, 0.1, 0, 10, 0, -0.1))

srs = osr.SpatialReference()
srs.SetWellKnownGeogCS("WGS84")
projection = srs.ExportToWkt()
ds.SetProjection(projection)

# write the raster
band = ds.GetRasterBand(1)
band.SetScale(0.01)
band.SetOffset(0)
band.SetNoDataValue(255)
band.WriteArray(raster)
ds = None

It produces the following errors:

ERROR 6: Seek not supported on writable /vsigs/ files
ERROR 1: _tiffSeekProc:No such file or directory
ERROR 1: _tiffWriteProc:No such file or directory
ERROR 1: /vsigs/<my-bucket-name>/test.tif:Error writing TIFF header
ERROR 1: _tiffWriteProc:No such file or directory
ERROR 6: Seek not supported on writable /vsigs/ files
ERROR 1: _tiffSeekProc:No such file or directory
ERROR 1: _tiffWriteProc:No such file or directory
ERROR 1: /vsigs/<my-bucket-name>/test.tif:Error writing TIFF header
ERROR 6: Seek not supported on writable /vsigs/ files
ERROR 1: _tiffSeekProc:No such file or directory
ERROR 1: _tiffWriteProc:No such file or directory
ERROR 1: /vsigs/<my-bucket-name>/test.tif:Error updating TIFF header

Do I have to do things in a different order or way for this to work?

The result is an 8B file in my GCS bucket.

Thanks,
Christoph

-- 

-------------------------------------------------------
Christoph Paulik
VanderSat // Satellite observed water data. Globally. Daily.
Wilhelminastraat 43a, 2011 VK, Haarlem (NL), The Netherlands
W: www.vandersat.com
M: +31 (0) 6 1827 1928
PGP: 8CFC D7DF 2867 B2DC 749B  1B0A 6E3B A262 5186 A0AC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20180719/70ce7ff3/attachment.sig>


More information about the gdal-dev mailing list