[FWTools] TIFFReadDirectoryCheckOrder:Invalid TIFF directory
Susana Iraiis Delgado Rodriguez
susana.delgado_s at utzmg.edu.mx
Mon Nov 29 10:37:52 EST 2010
Hello list:
I developed a python script to create an excel, which collects some data
from images with .tif, gtif, tiff, etc. When I run the module, it throws
warnings related to the type of .tiff images, I think it is because the
script doesn't make a difference between raster images and normal pictures.
Does anyone have ain idea how to make a difference of tii images?
The python module:
import sys, os, time, socket, codecs
from xlwt import Workbook
from osgeo import gdal
from osgeo.gdalconst import *
from PIL import Image
#Register GDAL drivers
gdal.AllRegister()
file_list = []
folders = None
for root, folders, files in os.walk( "C:\\" ):
file_list.extend(os.path.join(root,fi) for fi in files if
fi.endswith(".tif") or fi.endswith(".tiff") or fi.endswith(".gtif") or
fi.endswith(".ecw") or fi.endswith(".bil"))
wrkbk = Workbook()
wksht = wrkbk.add_sheet('raster')
wksht.row(0).write(0,'ruta')
wksht.row(0).write(1,'nombre')
wksht.row(0).write(2,'x_min')
wksht.row(0).write(3,'x_max')
wksht.row(0).write(4,'y_min')
wksht.row(0).write(5,'y_max')
wksht.row(0).write(6,'ancho_pixel')
wksht.row(0).write(7,'alto_pixel')
wksht.row(0).write(8,'num_filas')
wksht.row(0).write(9,'num_columnas')
wksht.row(0).write(10,'num_bandas')
wksht.row(0).write(11,'proyeccion')
wksht.row(0).write(12,'fecha_modificacion')
wksht.row(0).write(13,'maquina_host')
wksht.row(0).write(14,'usuario')
for row, filepath in enumerate(file_list, start=1):
wksht.row(row).write(0, unicode(filepath,errors='ignore'))
(ruta, filename) = os.path.split(filepath)
wksht.row(row).write(1, unicode(filename,errors='ignore'))
dataset = gdal.Open(filepath, GA_ReadOnly)
if dataset is None:
print 'Could not open...' +filename
else:
xOrigin, yOrigin, pixelWidth, pixelHeight, a, b =
dataset.GetGeoTransform()
geotransform = dataset.GetGeoTransform()
x_min = geotransform[0]
wksht.row(row).write(2,x_min)
y_max = geotransform[3]
wksht.row(row).write(5,y_max)
pixel_width = geotransform[1]
wksht.row(row).write(6,pixel_width)
pixel_height = geotransform[5]
wksht.row(row).write(7,pixel_height
rows = dataset.RasterYSize
cols = dataset.RasterXSize
bands = dataset.RasterCount
wksht.row(row).write(8,rows)
wksht.row(row).write(9,cols)
wksht.row(row).write(10,bands)
y_min = y_max + cols*geotransform[4] + rows*pixel_height
x_max = x_min + cols*pixel_width + rows*geotransform[2]
wksht.row(row).write(3,x_max)
wksht.row(row).write(4,y_min)
n = os.path.splitext(filepath)
tif = n[0]+'.tif'
tiff = n[0]+'.tiff'
gtif = n[0]+'.gtif'
ecw = n[0]+'.ecw'
bil = n[0]+'.bil'
if os.path.lexists(tif) or os.path.lexists(tiff) or os.path.lexists(gtif)
or os.path.lexists(ecw) or os.path.lexists(bil):
wksht.row(row).write(11, dataset.GetProjection()
else:
wksht.row(row).write(11, "No tiene proyeccion"
wksht.row(row).write(13, socket.gethostname())
wksht.row(row).write(14,os.environ.get("USERNAME"))
if os.path.lexists(filepath):
t = time.strftime("%m/%d/%Y %I:%M:%S
%p",time.localtime(os.path.getmtime(filepath)))
wksht.row(row).write(12, t)
else:
wksht.row(row).write(12, 'No se encontro el archivo')
wrkbk.save('rasters.xls')
The error that I got is:
Warning 1: TIFFReadDirectory:Unknown field with tag 2457 (0x999) encountered
Warning 1: TIFFReadDirectoryCheckOrder:Invalid TIFF directory; tags are not
sorted in ascending order
Warning 1: TIFFReadDirectory:Unknown field with tag 2457 (0x999) encountered
Warning 1: TIFFReadDirectoryCheckOrder:Invalid TIFF directory; tags are not
sorted in ascending order
More than 1000 errors or warnings have been reported. No more will be
reported from now.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20101129/a55ffc5f/attachment.htm
More information about the FWTools
mailing list