Skip to content

Coloring geometries based on data variables #107

@martibosch

Description

@martibosch

Hello!

I am using xvec to deal with observations from meteorological stations, and I am trying to plot the stations based on values derived from data variables (e.g., average temperature). Here is a MWE (see the data structures notebook for more context), working with meteora v0.3.0 (and the xvec optional requirements, i.e., pip install meteora[xvec]:

from meteora import utils
from meteora.clients import METARASOSIEMClient

region = "Switzerland"
start = "2021-08-13"
end = "2021-08-16"
variables = ["temperature", "precipitation", "surface_wind_speed"]

client = METARASOSIEMClient(region)
ts_df = client.get_ts_df(variables, start=start, end=end)

ts_cube = utils.long_to_cube(ts_df, client.stations_gdf, stations_gdf_id_col="id")

fig, ax = (
    ts_cube["temperature"].mean("valid").xvec.plot(cmap="coolwarm", geometry="station")
)

The resulting plot shows the station locations but not colored by the computed values. I went through the XvecAccessor.plot arguments and did not see how this can be done.

PD: on a side note, is it possible to have nicer labels for the geometries in legends rather than the WKT, e.g.:

ts_cube["temperature"].plot.line(x="valid", add_legend=True)

(again, see the notebook for more context).

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions