GDAL gtiff文件与颜色图保存

时间:2018-07-31 14:22:09

标签: python-2.7 tiff gdal

我需要对gtiff文件进行一些波段操作,并使用matplotlib中的colormap将其另存为新文件。

img1 = gdal.Open(fin+item)
red_band = img1.GetRasterBand(1)
red = red_band.ReadAsArray()
blue_band=img1.GetRasterBand(3)  
blue=blue_band.ReadAsArray()
red = red.astype(np.float64)
blue=blue.astype(np.float64)
np.seterr(divide='ignore', invalid='ignore')
new_arr=(red-blue)/2 # I have more complex calculations, it doesn't matter
b1=np.nanmean(new_arr)-3*np.nanstd(new_arr)
b4=np.nanmean(new_arr)+3*np.nanstd(new_arr)
plt.imsave(fout+item,new_arr,vmin=b1,vmax=b4,cmap=plt.cm.nipy_spectral)
outdata=gdal.Open(fout+item)
outdata.SetGeoTransform(img1.GetGeoTransform())
outdata.SetProjection(img1.GetProjection())

,所以我在输出文件夹name.tif图像中使用正确的颜色和name.tif.aux.xml得到了2个文件。但是结果图像没有地理配准。如何解决?

0 个答案:

没有答案