Let’s build a complete energy dashboard workflow. We’ll create a wind farm visualization with weather overlays - a comprehensive example that demonstrates the full power of the platform.
Let’s start by creating an empty dashboard that we can build upon:
# Create the dashboarddashboard = client.dashboards.create_dashboard( name="North Sea Wind Farm Dashboard", components=[], # We will create these later on)print(f"Created dashboard: {dashboard.id}")
You can now go to the dashboard page and see the dashboard you created. When opening it you will see that it is currently empty, so our next step is to add a component to it.
Let’s begin with a Map component, which can be used to create interactive visualizations with weather data, wind farms and more:
# Create a map component for our dashboardmap_component = client.components.create_map( name="Wind Farm Map", config={ "map_style": "mapbox://styles/mapbox/outdoors-v12" }, layer_ids=[] # We will create these later on)print(f"Created map component: {map_component.id}")
Lastly we need to add this new component to our existing dashboard, otherwise it will not be used. We do this using the API update call:
# Add our new component to the dashboardupdated_dashboard = client.dashboards.update_dashboard( dashboard.id, components=[map_component.id], # Add the Map Component id here)
Now if you open your dashboard again, you should see your new map component displayed. In the dashboard you can also drag and rescale your component to fit your use. However, the map component does not have any layers to display at the moment. So our next step is to create Map Layers and Weather Layers to show in your dashboard component.
Layers can be customized to visualize many different types of data and information. Let’s begin by creating a layer for wind data which we can then display with our existing map component:
# Create a weather layer for wind speedwind_speed_layer = client.layers.create_layer( name="Wind Speed at 10m", type="wl:RasterLayer", weather_model_id="ECMWF_IFS", variable="WindSpeed", altitude=10, run_day="latest", run_hour="0", deckgl_props={ "opacity": 0.7 })print(f"Created weather layer: {wind_speed_layer.id}")
Next, let’s create a layer showing our windfarms. To do this, we first need to create a dataset with the data for our windfarms:
Next, to visualize those turbines on our map we create a new layer for them. This layer is similar to the one we made previously for wind data, but instead of information for weather data models we will specify the type as a “ScatterPlotLayer” and add the id for the dataset we just created:
Finally, for these two new layers to show up in our Map component, we also need to add their layer IDs to the component. We do this by updating the map component with the “update” API call:
# Update the map component with our new Weather Layerupdated_map_component = client.components.update_map( map_component.id, layer_ids=[wind_speed_layer.id, wind_turbines_layer.id] # Add your Layer ids here)print(f"Updated map component: {map_component.id} with Weather Layer: {wind_speed_layer.id} and Turbine Layer: {wind_turbines_layer.id}")
Now if you go back to your dashboard, you will see the layers displayed:You can also drag the map component to give it the size and position that suits your needs: