一、 降雨 nc 数据下载
1. 登录网址(截至到20240712仅有2024年1月的降雨量)
https://www.ncei.noaa.gov/products/climate-data-records/precipitation-cmorph
2. 选择对应时间分辨率
8km×8km (30 min), 0.25°×0.25° (hourly, daily)(覆盖全球60°S-60°N))
--------- 这里以天为例:
3. 选择对应时间 nc 下载
4. 使用 python 批量下载
基于https://blog.csdn.net/weixin_45135078/article/details/138766135修改
# -*- coding: utf-8 -*-
import os
import calendar
import requests
from bs4 import BeautifulSoup
import concurrent.futures
# 降雨量数据时空分辨率:8km×8km(30 min), 0.25°×0.25° (hourly, daily)(覆盖全球60°S - 60°N))
def download_file(out_fl_path, url, year, month, day):
if day != '':
download_url = url + str(year) + '/' + f"{month:02d}/" + f"{day:02d}/"
savePath = out_fl_path + str(year) + '/' + f"{month:02d}/" + f"{day:02d}/"
else:
download_url = url + str(year) + '/' + f"{month:02d}/"
savePath = out_fl_path + str(year) + '/' + f"{month:02d}/"
# print(download_url)
response = requests.get(download_url)
soup = BeautifulSoup(response.text, 'html.parser')
if not os.path.exists(savePath):
os.makedirs(savePath)
for link in soup.select('a[href$=".nc"]'):
name = link['href']
nc = requests.get(download_url + name)
with open(os.path.join(savePath, name), 'wb') as file:
file.write(nc.content)
print(name, '下载完成')
def get_rain_nc_from_cmorph(out_fl_path, time_resolution, year_start, year_end, month_start=1, month_end=12):
url_pre = 'https://www.ncei.noaa.gov/data/cmorph-high-resolution-global-precipitation-estimates/access/'
url = ''
if time_resolution == 1: # 30min
url = url_pre + '30min/8km/'
elif time_resolution == 2: # hourly
url = url_pre + 'hourly/0.25deg/'
elif time_resolution == 3: # daily
url = url_pre + 'daily/0.25deg/'
if url.split('/')[-3] == 'daily':
day = ''
with concurrent.futures.ThreadPoolExecutor(max_workers=12) as exe_code:
future_url = {exe_code.submit(download_file, out_fl_path, url, year, month, day): (year, month, day) for year
in range(year_start, year_end + 1) for month in range(month_start, month_end+1)}
else:
with concurrent.futures.ThreadPoolExecutor(max_workers=12) as exe_code:
future_url = {exe_code.submit(download_file, out_fl_path, url, year, month, day): (year, month, day) for year
in range(year_start, year_end + 1) for month in range(month_start, month_end+1) for day in
range(1, calendar.monthrange(year, month)[1] + 1)}
if __name__ == '__main__':
output_path = '.\\'
time_kind = 3 # daily
start_year = 2023 # 开始年
end_year = 2024 # 结束年
get_rain_nc_from_cmorph(output_path, time_kind, start_year, end_year)
# start_month = 1 # 开始月,默认为1
# end_month = 2 # 结束月,默认12
# get_rain_nc_from_cmorph(output_path, time_kind, start_year, end_year, start_month, end_month)
二、进行 nc 文件读取,并生成 tif 栅格
待更新...
数据介绍及下载参考视频网址:https://www.bilibili.com/video/BV1yb421H7rF