【发布时间】:2020-11-20 11:32:57
【问题描述】:
我正在尝试使用 Python 从多光谱照片中计算多光谱植被指数。
到目前为止,我已经计算出NDVI,因为网上有很多例子,所以很容易实现。
#Read the image file
image_file = "my_tif_image.tif"
with rasterio.open(image_file) as src:
band_red = src.read(3)
with rasterio.open(image_file) as src:
band_nir = src.read(4)
# Allow division by zero
numpy.seterr(divide='ignore', invalid='ignore')
band_nir = numpy.array(band_nir)
band_red = numpy.array(band_red)
NDVI = (band_nir.astype(float) - band_red.astype(float)) / (band_nir + band_red)
fig1, ax = plt.subplots(figsize=(12, 12))
fig1 = plt.gcf()
ep.plot_bands(NDVI,
cmap='PiYG',
scale=False,
cbar = False, #Change this to TRUE to display the color bar
ax=ax,
vmin=-1, vmax=1,
title="NDVI")
plt.show()
fig1.savefig('NDVI.png',bbox_inches='tight')
但是,除了上述索引之外,我无法找到任何关于如何计算其他索引的示例(至少是我感兴趣的那些)。
例如,我尝试了烧毁面积指数的公式,而不是 NDVI 指数:
BIR = 1.0 / (((0.1 + band_red) ** 2) + ((0.06 + band_nir) ** 2))
但我得到一个空图,并且计算出的数组数量非常小(在 10^-9 的数量中)。
我的问题是,为什么很难找到计算和绘制除 NDVI 以外的指数的示例?最后,如果我不能用 python 做到这一点,还有其他编程方式吗?
【问题讨论】: