卫星降雨量数据下载及生成栅格分布图(CMORPH)

一、 降雨 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 url.split('/')[-3] == 'daily':
        download_url = url + str(year) + '/' + f"{month:02d}/"
        savePath = out_fl_path + str(year) + '/' + f"{month:02d}/"
    else:
        download_url = url + str(year) + '/' + f"{month:02d}/" + f"{day:02d}/"
        savePath = out_fl_path + str(year) + '/' + f"{month:02d}/" + f"{day: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/'
    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)

4. 进行 nc 文件读取,并生成 tif 栅格

待更新...

 数据介绍及下载参考视频网址:https://www.bilibili.com/video/BV1yb421H7rF

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值