该文章主要完成: 1、定制下载ERA5数据 2、nc数据提取为各个单波段影像 3、提取后的各个波段进行栅格运算和保存
1、定制下载ERA5数据 ERA在线编译器下载ERA5数据:利用数据平台的在线编译器toolbox-editor,编写脚本文件,将GRIB格式数据转为nc格式进行下载,脚本如下: API下载ERA5数据
import cdsapi
c = cdsapi.Client()
for i in range (2019,2020):
print (i)
c.retrieve(
'reanalysis-era5-single-levels-monthly-means',
{
'product_type': 'monthly_averaged_reanalysis',
'variable': 'total_precipitation',
'year': str(i),
'month': [
'01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12',
],
'time': '00:00',
'format': 'netcdf',
},
'%sera5tp.nc' %(i))
2、nc数据处理 arcpy.MakeNetCDFRasterLayer_md工具介绍 arcpy.CopyRaster_management工具介绍 arcpy.MakeRasterLayer_management工具介绍
#coding=utf-8
import arcpy
import os
from arcpy.sa import *
#增加模块
arcpy.CheckOutExtension("spatial")
for i in range(1979,2020):
print('start')
#%s_ERA_ECV_air_temperature.nc 原始数据
arcpy.MakeNetCDFRasterLayer_md(in_netCDF_file="【目录】/%s_ERA_ECV_air_temperature.nc" %str(i),
variable="tas",
x_dimension="lon",
y_dimension="lat",
out_raster_layer="tas_Layer%s" %str(i),
band_dimension="time",
dimension_values="",
value_selection_method="BY_VALUE")
#%stas.tif 已经将nc数据转为多波段的tif
arcpy.CopyRaster_management(in_raster="tas_Layer%s" %str(i),
out_rasterdataset="【目录】/%stas.tif" %str(i),
config_keyword="",
background_value="",
nodata_value="1.#QNAN0e+000",
onebit_to_eightbit="NONE",
colormap_to_RGB="NONE",
pixel_type="",
scale_pixel_value="NONE",
RGB_to_Colormap="NONE"
)
for j in range(1,13):
print "MakeRas_tif%s_%s" %(str(i),str(j))
arcpy.MakeRasterLayer_management("【目录】/%stas.tif" %str(i),"MakeRas_tif%s_%s" %(str(i),str(j)),"#","-180.125 -90.125 179.875 90.125","%s" %str(j))
outPlus = Raster("MakeRas_tif%s_1" %str(i)) + Raster("MakeRas_tif%s_2" %str(i))
outPlus.save("【目录】/%savetas.tif" %str(i))
print('end')
评论