温度植被干旱指数TVDI(Temperature Vegetation Dryness Index)是一种基于光学与热红外遥感通道数据进行植被覆盖区域表层土壤水分反演的方法。

1、原理

LST-NDVI特征空间1:

温度植被干旱指数(TVDI)的计算方法为:

TVDI= LST max ​ −LST min ​ LST−LST min ​ ​

LSTmin​=a+b×NDVI

LSTmax​=c+d×NDVI

其中
                                                           a 、 b 、 c 、 d 
为干、湿边拟合系数;

2、Python代码

import gdal
from gdalconst import *
import numpy as np
from glob import glob
from os import path as osp
import os, subprocess
import matplotlib.pyplot as plt# 获取lst、ndvi数据
def get_data(file_ndvi,file_lst):ndvi_tif=gdal.Open(file_ndvi,GA_ReadOnly)lst_tif=gdal.Open(file_lst,GA_ReadOnly)ndvi_band=ndvi_tif.GetRasterBand(1)ndvi=ndvi_band.ReadAsArray()lst_band=lst_tif.GetRasterBand(1)lst=lst_band.ReadAsArray()    return ndvi,lst# 获取投影等信息,用于保存TVDI结果
def get_info(file_ndvi):ndvi_tif=gdal.Open(file_ndvi,GA_ReadOnly)ndvi_band=ndvi_tif.GetRasterBand(1)gt = ndvi_tif.GetGeoTransform()proj = ndvi_tif.GetProjectionRef()dtype = ndvi_band.DataTypereturn gt,proj,dtype# 计算lst的最小值(湿边)和最大值(干边)
def get_min_max(ndvi,lst):MiniList = []MaxList = []# 创建ndvi向量(0到1,间距为0.01)ndvi_vector = np.round(np.arange(0.01, 1.01, 0.01), 2)# 首先找到相同ndvi的lst值for val in ndvi_vector:lst_lst_val = []row, col = np.where((ndvi >= val-0.001) & (ndvi <= val+0.001))# 根据这些ndvi的位置,我们取温度值对应这些位置(行和列)for i in range(len(row)):if np.isfinite(lst[row[i], col[i]]):lst_lst_val += [lst[row[i], col[i]]]# 如果所需的ndvi有lst值,则计算最大值和最小值if lst_lst_val != []:lst_min_val = np.min(lst_lst_val)lst_max_val = np.max(lst_lst_val)else:lst_min_val = np.nanlst_max_val = np.nan# 找到的值被添加到MiniList和MaxList列表中MiniList += [lst_min_val]MaxList  += [lst_max_val]return MiniList,MaxListdef fit(MiniList,MaxList):ndvi_vector = np.round(np.arange(0.01, 1.01, 0.01), 2)MiniList_fin = []ndvi_fin = []for i, val in enumerate(MiniList):if np.isfinite(val):MiniList_fin += [val]ndvi_fin += [ndvi_vector[i]]MinPfit = np.polyfit(ndvi_fin[14:89], MiniList_fin[14:89], 1)MaxList_fin = []ndvi_fin = []for i, val in enumerate(MaxList):if np.isfinite(val):MaxList_fin += [val]ndvi_fin += [ndvi_vector[i]]MaxPfit = np.polyfit(ndvi_fin[14:89], MaxList_fin[14:89], 1)return MinPfit,MaxPfitdef plot_scatter(ndvi,lst,MiniList,MaxList,MinPfit,MaxPfit,scatter_file=None):ndvi_vector = np.round(np.arange(0.01, 1.01, 0.01), 2)a1, b1 = MaxPfita2, b2 = MinPfitlinhamax = [b1 + (a1 * 0), b1 + (a1 * 1)]linhamin = [b2 + (a2 * 0), b2 + (a2 * 1)]plt.plot(ndvi.ravel(), lst.ravel(), "+", color='dimgray', markersize=4)plt.plot(ndvi_vector[14:89], MiniList[14:89], '+', color='b')plt.plot(ndvi_vector[14:89], MaxList[14:89], '+', color='r')if a1>0:plt.plot([0, 1], linhamax, color='r', markersize=8,\label=f"Tsmax = {'%.1f'% b1} + {'%.1f' % abs(a1)} * ndvi")else:plt.plot([0, 1], linhamax, color='r', markersize=8,\label=f"Tsmax = {'%.1f'% b1} - {'%.1f' % abs(a1)} * ndvi")if a2>0:plt.plot([0, 1], linhamin, color='b', markersize=8,\label=f"Tsmin = {'%.1f' % b2} + {'%.1f' % abs(a2)} * ndvi")else:plt.plot([0, 1], linhamin, color='b', markersize=8,\label=f"Tsmin = {'%.1f' % b2} - {'%.1f' % abs(a2)} * ndvi")plt.legend(loc='upper right', fontsize=12)plt.ylim(top=340,bottom=270)plt.xlabel("ndvi")plt.ylabel("lst (K)")plt.title("ndvi vs lst Scatterplot")if scatter_file is not None:plt.savefig(scatter_file)plt.show()def show_tvdi(tvdi,fig_file=None):plt.imshow(tvdi,cmap= 'jet_r',vmax=1,vmin = 0)plt.axis('off')plt.colorbar()plt.title("tvdi")if fig_file is not None:plt.savefig(fig_file)plt.show()def compute_tvdi(ndvi,lst,MinPfit,MaxPfit):a1, b1 = MaxPfita2, b2 = MinPfitTs_max = b1 + (a1 * ndvi)Ts_min = b2 + (a2 * ndvi)TVDI = (lst - Ts_min) / (Ts_max - Ts_min)return TVDIdef save_tvdi(TVDI,gt,proj,dtype,file_out):fname_out   = file_outdriver      = gdal.GetDriverByName('GTiff')data_type   = dtypedset_output = driver.Create(fname_out, TVDI.shape[1], TVDI.shape[0], 1, gdal.GDT_Float32)dset_output.SetGeoTransform(gt)dset_output.SetProjection(proj)dset_output.GetRasterBand(1).WriteArray(TVDI)dset_output.FlushCache()dset_output = Nonedef main(ndvi_file,lst_file,tvdi_file,scatter_file=None,fig_file=None):'''Parameters----------ndvi_file : the file of ndvilst_file : the file of lsttvdi_file : the file use to save tvdiscatter_file : the file use to save scatterfig_file : the file use to save the figure of tvdi'''# 获取ndvi和lst数据ndvi,lst=get_data(ndvi_file,lst_file)ndvi[ndvi<0]=np.nanlst[lst<250]=np.nan# 获取lst的最小值(湿边)和最大值(干边)MiniList,MaxList=get_min_max(ndvi,lst)# 计算tvdi,并保存MinPfit,MaxPfit=fit(MiniList,MaxList)tvdi=compute_tvdi(ndvi,lst,MinPfit,MaxPfit)gt,proj,dtype=get_info(ndvi_file)save_tvdi(tvdi,gt,proj,dtype,tvdi_file)# 显示散点图plot_scatter(ndvi,lst,MiniList,MaxList,MinPfit,MaxPfit,scatter_file)# 展示tvdi结果show_tvdi(tvdi,fig_file)if __name__ == '__main__':ndvi_file=r'*.tif'lst_file=r'*.tif'tvdi_file=r'*.tif'main(ndvi_file,lst_file,tvdi_file)

3、结果展示
LST-NDVI的散点图:

TVDI展示:

如果对您有用的话,别忘了给点个赞哦_ !数据来源请引用:地理遥感生态网科学数据注册与出版系统

4、参考文献
[1] Du L, Song N, Liu K, et al. Comparison of Two Simulation Methods of the Temperature Vegetation Dryness Index (TVDI) for Drought Monitoring in Semi-Arid Regions of China[J]. Remote Sensing, 2017, 9(2): 177.

Python计算温度植被干旱指数(TVDI)相关推荐

  1. Python应用实战案例-Python使用MODIS数据实现温度植被干旱指数TVDI的计算

    1.数据下载 数据及代码参见温度植被干旱指数TVDI 采用的数据为MODIS植被指数产品MOD13A3.地表温度产品MOD11A2以及SRTM DEM产品. MODIS数据来源于美国航空航天局(Nat ...

  2. 使用插件对温度植被干旱指数进行计算

    使用插件对温度植被干旱指数进行计算 软件平台 ENVI5.3软件 插件:tvdi 背景 土壤水分是旱情监测的一个重要指标,利用遥感技术快速获得大面积区域内土壤水分对旱情监测意义重大.20世纪末,以遥感 ...

  3. Python 计算思维训练——字典与字符串练习

    Python 计算思维训练--字典与字符串练习(一) 基于表格创建字典 - 物理常数存储 #coding=utf-8 import re # 请在此处填写代码 #********** Begin ** ...

  4. 再说不会用python计算地球表面多边形面积,可不能了!(记录五种可行方法)

    由于地理投影导致导致每个像元实际地面面积不同,越靠近北极实际面积越小,越靠近赤道实际面积越大,如果不进行面积加权就简单平均,会导致温度较实际温度偏低. 直接使用卫星地图的计算面积功能就会遇到这样的问题 ...

  5. 温度转换python代码解释_如何用python代码温度转换?

    如何用python代码温度转换? 用python代码温度转换的方法: 步骤一:分析问题的计算部分 步骤二:确定功能,使用IPO方法进一步分析 输入:华氏或者摄氏温度值.温度标识 处理:温度转化算法 输 ...

  6. 使用OpenCV和Python计算图像的“彩色度”

    使用OpenCV和Python计算图像"彩色度" 1. 效果图 2. 炫彩度量方法是什么? 3. 源代码 参考 你是否尝试过计算每个图像的炫彩值,并根据炫彩值对自己的图像数据集进行 ...

  7. Python计算训练数据集(测试集)中某个分类变量阴性(阳性)标签样本的不同水平(level)或者分类值的统计个数以及比例

    Python计算训练数据集(测试集)中某个分类变量阴性(阳性)标签样本的不同水平(level)或者分类值的统计个数以及比例 目录

  8. Python计算两个numpy数组的交集(Intersection)实战:两个输入数组的交集并排序、获取交集元素及其索引、如果输入数组不是一维的,它们将被展平(flatten),然后计算交集

    Python计算两个numpy数组的交集(Intersection)实战:两个输入数组的交集并排序.获取交集元素及其索引.如果输入数组不是一维的,它们将被展平(flatten),然后计算交集 目录

  9. Python使用datetime中的timedelta模块实现时间增减:python计算100天后是哪年那月那日?

    Python使用datetime中的timedelta模块实现时间增减:python计算100天后是哪年那月那日? 目录

最新文章

  1. 三维激光重建原理与实现HALCON
  2. Reroute Unassigned Shards——遇到主shard 出现的解决方法就是重新路由
  3. boost::make_nvp用法的实例
  4. cookies,sessionStorage 和 localStorage 的区别?
  5. 797B. Odd sum
  6. 49 - 算法 - Leetcode-111 -二叉树的最小深度 -递归循环
  7. golang编译时报错:Get “https://proxy.golang.org/github.com/antihax/optional/@v/v1.0.0.mod“: dial tcp 172.2
  8. 图像处理十:图像反色
  9. vue 通信PHP,Vue组件通信(详细教程)
  10. Armbian搭建本地Gitea服务器
  11. 教育培训机构屡遭投诉?湖南中创教育给出三点建议
  12. Idea一键导入所有缺省的包
  13. 使用python获取美股行情数据
  14. 交流充电桩电路图_交流充电桩工作原理,直流充电桩和交流充电桩的区别
  15. 【观察】亚信科技:“三新”收入再翻番背后,是全栈数智化能力的释放
  16. android官方降级包,OPPOK3 ColorOS刷机包(官方最新固件升级包安卓10 ColorOS V6)
  17. linux的gdb命令bt,Linux 程序调式命令 GDB 概述
  18. 百分百解决win10蓝屏问题,硬件损坏除外
  19. 刷同样多数学题,你的成绩还是不如我(来自网络)
  20. 开源SPL强化MangoDB计算

热门文章

  1. HDFS、Ceph文件系统以及Hbase、Cassendra、TiDB比较
  2. 关于泰勒展开的细节-《三体》读后感的读后感
  3. 文件服务器隐藏netlogon,lanmanworkstation-netlogon服务无法自启,该如何处理?各位大侠好,此台服务器 爱问知识人...
  4. 常用外贸群发邮件模板,海外邮件
  5. 最新时下最火的盲盒商城源码/视频搭建教程
  6. Android P SystemUI之StatusBar UI布局status_bar.xml解析
  7. KingbaseES V8R6 ksql 关闭自动提交
  8. 美国互联网影视的盈利模式 —— Netflix模式
  9. MySQL索引(详细,1万字长文)
  10. 转自啄木鸟学院-IT行业培训班出来的人真的不行吗?