NOAA.Observations (NOAA Observations v0.4.37) View Source

Fetches weather observations for a US state/territory.

Link to this section Summary

Link to this section Functions

Link to this function

fetch(state, url_templates \\ [state: "https://w1.weather.gov/xml/current_obs/seek.php?state=<%=state%>&Find=Find", station: "https://w1.weather.gov/xml/current_obs/display.php?stid=<%=station%>"])

View Source

Specs

Fetches weather observations for a US state/territory.

Returns a tuple of either {:ok, [obs]} or {:error, text}.

Parameters

  • state - US state/territory code
  • url_templates - URL templates (keyword)

URL templates

  • :state - URL template for a state (EEx string)
  • :station - URL template for a station (EEx string)

Examples

iex> alias NOAA.Observations
iex> {:ok, observations} = Observations.fetch("vt")
iex> Enum.all?(observations, &is_map/1) and length(observations) > 0
true