I am trying to plot the latest wind speeds from https://developers.google.com/earth-engine/datasets/catalog/ECMWF_ERA5_DAILY . It is supposedly an "ImageCollection". When I run the code below, I get the traceback "EEException: Image.visualize: Parameter 'image' is required.". I've added an i_date just to be sure I search over a reasonable range of dates - to make sure there's data available.
May I know where I may have gotten it wrong / how I may work around this issue? Thank you very much!
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 © <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")