首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Python/Folium中绘制ERA5日风速-找不到

在Python/Folium中绘制ERA5日风速-找不到
EN

Stack Overflow用户
提问于 2022-07-02 13:30:36
回答 1查看 182关注 0票数 0

我正在试图绘制最新的风速https://developers.google.com/earth-engine/datasets/catalog/ECMWF_ERA5_DAILY。它被认为是一个"ImageCollection“。当我运行下面的代码时,我会得到回溯"EEException: Image.visualize:参数‘映像是必需的“。我增加了一个i_date,以确保我搜索一个合理的日期范围-以确保有可用的数据。

我能知道我在哪里搞错了/我如何解决这个问题?非常感谢!

代码语言:javascript
复制
import ee

# Trigger the authentication flow.
ee.Authenticate()

# Initialize the library.
ee.Initialize()


wind = ee.ImageCollection('ECMWF/ERA5/DAILY')
i_date = '2022-04-28'
f_date = '2022-07-01'
wind= ee.ImageCollection('ECMWF/ERA5/DAILY')

import folium


def add_ee_layer(self, ee_image_object, vis_params, name):
    """Adds a method for displaying Earth Engine image tiles to folium map."""
    map_id_dict = ee.Image(ee_image_object).getMapId(vis_params)
    folium.raster_layers.TileLayer(
        tiles=map_id_dict['tile_fetcher'].url_format,
        attr='Map Data &copy; <a href="https://earthengine.google.com/">Google Earth Engine</a>',
        name=name,
        overlay=True,
        control=True
    ).add_to(self)

# Add Earth Engine drawing method to folium.
folium.Map.add_ee_layer = add_ee_layer

wind_img=wind.select('u_component_of_wind_10m').filterDate(i_date,f_date).first()
# wind_img=wind_img.mean()

# Set visualization parameters for land surface temperature.
wind_vis_params = {
    'min': 0, 'max': 40,
    'palette': ['white', 'blue', 'green', 'yellow', 'orange', 'red']}

ee_tiles_names = ['Land Surface Temperature']

# Create a new map.
lat, lon = 45.77, 4.855
my_map = folium.Map(location=[lat, lon], zoom_start=5)

# Add layers to the map using a loop.
my_map.add_ee_layer(wind_img, wind_vis_params, 'Wind Speed')

my_map.add_child(folium.LayerControl())
folium.LayerControl(collapsed = False).add_to(my_map)

my_map.save("c:/data/weather.html")
import webbrowser
webbrowser.open("c:/data/weather.html")
EN

回答 1

Stack Overflow用户

发布于 2022-07-02 13:36:57

我真是太蠢了。我刚刚意识到数据集将于2020年结束。以下是修改后的代码:

代码语言:javascript
复制
# -*- coding: utf-8 -*-
"""
Created on Fri Jul  1 10:04:39 2022

@author: xxx
"""

import ee

# Trigger the authentication flow.
ee.Authenticate()

# Initialize the library.
ee.Initialize()


wind = ee.ImageCollection('NOAA/GFS0P25')
i_date = '2022-06-30'
f_date = '2022-07-01'
# wind= ee.ImageCollection('ECMWF/ERA5/DAILY')

import folium


def add_ee_layer(self, ee_image_object, vis_params, name):
    """Adds a method for displaying Earth Engine image tiles to folium map."""
    map_id_dict = ee.Image(ee_image_object).getMapId(vis_params)
    folium.raster_layers.TileLayer(
        tiles=map_id_dict['tile_fetcher'].url_format,
        attr='Map Data &copy; <a href="https://earthengine.google.com/">Google Earth Engine</a>',
        name=name,
        overlay=True,
        control=True
    ).add_to(self)

# Add Earth Engine drawing method to folium.
folium.Map.add_ee_layer = add_ee_layer

wind_img=wind.select('u_component_of_wind_10m_above_ground').filterDate(i_date,f_date).first()
# wind_img=wind_img.mean()

# Set visualization parameters for land surface temperature.
wind_vis_params = {
    'min': 0, 'max': 40,
    'palette': ['white', 'blue', 'green', 'yellow', 'orange', 'red']}

ee_tiles_names = ['Wind Speed']

# Create a new map.
lat, lon = 45.77, 4.855
my_map = folium.Map(location=[lat, lon], zoom_start=5)

# Add layers to the map using a loop.
my_map.add_ee_layer(wind_img, wind_vis_params, 'Wind Speed')

my_map.add_child(folium.LayerControl())
folium.LayerControl(collapsed = False).add_to(my_map)

my_map.save("c:/data/weather.html")
import webbrowser
webbrowser.open("c:/data/weather.html")
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72839424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档