GDAL读取与存储TIF的问题

46 views
Skip to first unread message

GoogleWind

unread,
Sep 16, 2009, 3:19:04 AM9/16/09
to gdal+python+GIS+geosings论坛
将一个数据输入到TIF并保存,再读TIF数组,发现数组不是原来存储的数组。如下所示:

arr != mapArr,mapArr是实数,有小数点,而arr全部是整数,而且数值也差很多。Why?

谢谢。

源程序:
driver=gdal.GetDriverByName("GTiff")
NewImage=driver.Create(tifName,col,row,1,options=["INTERLEAVE=PIXEL"])
NewImage.WriteRaster(0,0,col,row,mapArr.tostring(),col,row,band_list=
[1])
NewImage.SetGeoTransform( [40488800, 125, 0, 3492500, 0, -125 ] )

dataset=gdal.Open(tifName)
Width=dataset.RasterXSize
Height=dataset.RasterYSize
Band=dataset.GetRasterBand(1)
arr=Band.ReadAsArray(0,0,Width,Height)


linux23...@gmail.com

unread,
Nov 8, 2009, 8:15:10 PM11/8/09
to gdal+python+GIS+geosings论坛
Create(self, filename, xsize, ysize, bands=1, datatype=1, options=[])
method of
仔细看下那个datatype参数,如果创建的是Byte,什么数据进来都是Byte
Reply all
Reply to author
Forward
0 new messages