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:\BaiduNetdiskDownload\new WSI\NDVI.mdb'
luccpath=r'E:\BaiduNetdiskDownload\new WSI\Catchment_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:\FireFoxDownload\CDRMVCCN.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')

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冬_冬_

若觉得文章对您有用,请随意打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值