ArcPy最大值法由NDVI月度数据转化为年度数据

ArcPy最大值法由NDVI月度数据转化为年度数据,第1张

ArcPy最大值法由NDVI月度数据转化为年度数据 下载中国5km分辨率逐月NDVI数据集(1982-2020)

目录

下载中国5km分辨率逐月NDVI数据集(1982-2020)

配置python环境

编写代码


下载地址:国家地球系统科学数据中心数据详细信息http://www.geodata.cn/data/datadetails.html?dataguid=239118756960240&docid=474

配置python环境

配置方法可以参考我的另一篇文章

 Pycharm中安装arcpy_冬_冬_的博客-CSDN博客_arcpy安装

编写代码
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project :arcpy_WSI 
@File    :NDVI_sum.py
@Author  :Ryo
@Date    :2021/12/8 19:55 
'''
'''This program is for calculate annual NDVI dataset by monthly dataset '''
import arcpy
arcpy.env.overwriteOutput = True
from arcpy import env
from arcpy.sa import *
import os
import re
env.workspace = r'E:BaiduNetdiskDownloadnew WSINDVI.mdb'
luccpath=r'E:BaiduNetdiskDownloadnew WSICatchment_LUCC'
arcpy.CheckOutExtension("spatial")
arcpy.gp.overwriteOutput = 1
arcpy.env.overwriteOutput = 1

# Convert tiff dataset to rasters
for i in range(1,468):
    year=1982+i//12
    month=i%12+1
    print(year,month)
    if year<2000:#Extract data after 2000
        continue
    ##Create raster layer from single raster dataset with clipping feature
    arcpy.MakeRasterLayer_management(r"E:FireFoxDownloadCDRMVCCN.tiff", "rdlayer", "#", "", str(i))
    arcpy.CopyRaster_management("rdlayer",str(year)+str(month))

for year in range(2000,2021):# turn monthly data to annualdata by max
    # Check out the ArcGIS Spatial Analyst extension license
    arcpy.CheckOutExtension("Spatial")

    # Execute CellStatistics
    outCellStatistics = CellStatistics([Raster(str(year)+str(month)) for month in range(1,13)], "MAXIMUM", "DATA")

    # Save the output
    outCellStatistics.save("NDVI"+str(year))
    print(year,'finished')

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5651761.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存