Today I'm in trouble because for the first time I have to work with TIFF files, and I have an error. I'm trying to grab a raster with the values of pollution agents in Europe, so I'm not interesting to keep an high level of resolution of the image, but only to keep data, I can manipulate the image. My code is very simple:
from __future__ import print_function
import numpy
import urllib2
from PIL import Image
f = open('./maccrasters/prova.tif','w')
fullMap = urllib2.urlopen("http://wdc.dlr.de/wdcservices/wcs.php?COVERAGE=17e72d93-76d9-4af6-9899-b7b04e2763c8&service=wcs&version=1.0.0&crs=epsg:4326&bbox=-25,30,45,70&RESX=0.1&RESY=0.1&request=getcoverage&format=application/x-tiff-32f&TIME=2015-12-13T00&elevation=0&OUTPUTFILENAME=17e72d93-76d9-4af6-9899-b7b04e2763c8_2015-12-13T00_0")
im = Image.open(fullMap)
print(im.format, im.size, im.mode) # output is TIFF (700,400) F
im.show()
im.save(f, "TIFF")
The system returns me an output and I can't find a solution for that error:
_TIFFVSetField: ./maccrasters/prova.tif: Invalid tag "TileOffsets" (not supported by codec).
Traceback (most recent call last):
File "getrasters.py", line 20 in <module>
im.save(f, "TIFF")
File "C:\Python27\lib\site-packages\PIL\Image.py", line 1665, in save
save_handler(self, fp, filename)
File "C:\Python27\lib\site-packages\PIL\TiffImagePlugin.py", line 1307, in _save
e = Image._getencoder(im.mode, 'libtiff', a, im.encoderconfig)
File "C:\Python27\lib\site-packages\PIL\Image.py",line 430, in _getencoder
return encoder(mode, *args + extra)
RuntimeError: Error setting from dictionary
Someone can help me?