Function Repository Resource:

CurrentWeatherData

Source Notebook

Get the current weather for a location

Contributed by: Jason Martinez

ResourceFunction["CurrentWeatherData"][loc]

returns the latest available weather property values for the location loc.

ResourceFunction["CurrentWeatherData"][loc,property]

returns the latest available weather property value for the location loc.

ResourceFunction["CurrentWeatherData"][]

returns the latest available weather property values for the location associated with $GeoLocation.

Details and Options

loc can be a weather station using an ICAO code such as "KNYC", an Entity with a specific location or a GeoPosition.
loc can also be a list of valid locations.
ResourceFunction["CurrentWeatherData"] returns an Association of results when a list of locations is specified. The weather stations for those locations are used as the keys.
Properties include:
"CloudCoverFraction"fraction of the sky obscured by cloud cover
"Conditions"list of weather conditions (fog, tornado, thunderstorm)
"DewPoint"dew point temperature
"Humidity"relative humidity
"PrecipitationAmount"the most recent precipitation amount and duration
"PrecipitationRate"average precipitation rate
"PrecipitationTypes"types of precipitation observed (hail, rain, snow)
"Pressure"barometric pressure in hectopascals
"Temperature"temperature
"TimeStamp"the most recent weather recording time
"WindChill"wind chill temperature
"WindDirection"wind direction in angular degrees
"WindSpeed"steady wind speed
Where applicable, results are returned as a Quantity. "TimeStamp" is returned as a DateObject.
ResourceFunction["CurrentWeatherData"] returns an Association for the single argument case and when multiple properties are requested. The property names are used as the keys.
ResourceFunction["CurrentWeatherData"] takes the option UnitSystem. UnitSystem can take the values "Metric" or "Imperial". By default, this uses the value of $UnitSystem.
ResourceFunction["CurrentWeatherData"] is optimized for returning all property values for lists of locations.

Examples

Basic Examples (3) 

Obtain the latest weather conditions for the default $GeoLocation:

In[1]:=
ResourceFunction["CurrentWeatherData"][]
Out[1]=

Obtain the latest weather conditions for a weather station:

In[2]:=
ResourceFunction["CurrentWeatherData"]["KISP"]
Out[2]=

Get the latest recorded temperature for a Chicago:

In[3]:=
ResourceFunction["CurrentWeatherData"][
 Entity["City", {"Chicago", "Illinois", "UnitedStates"}], "Temperature"]
Out[3]=

Obtain current temperature and pressure for Madrid:

In[4]:=
ResourceFunction["CurrentWeatherData"][
 Entity["City", {"Madrid", "Madrid", "Spain"}], {"Temperature", "Pressure"}]
Out[4]=

Scope (4) 

Find current weather for entities that possess a position property:

In[5]:=
ResourceFunction["CurrentWeatherData"][
 Entity["Building", "EiffelTower::5h9w8"]]
Out[5]=

Use GeoPosition to specify the location:

In[6]:=
ResourceFunction["CurrentWeatherData"][
 GeoPosition[{51.5`, -0.1166667`}]]
Out[6]=

Request current weather for multiple locations at once:

In[7]:=
ResourceFunction["CurrentWeatherData"][{"KISP", "KSAC", "KCMI"}]
Out[7]=

Find the current temperature and pressure for the 10 largest cities in the United States:

In[8]:=
ResourceFunction["CurrentWeatherData"][
 EntityList[
  EntityClass[
   "City", {EntityProperty["City", "Country"] -> Entity["Country", "UnitedStates"], EntityProperty["City", "Population"] -> TakeLargest[10]}]], {"Temperature", "Pressure"}]
Out[8]=

Options (1) 

Control the units returned for results by using the UnitSystem option:

In[9]:=
ResourceFunction["CurrentWeatherData"]["KCMI", UnitSystem -> "Metric"]
Out[9]=
In[10]:=
ResourceFunction["CurrentWeatherData"]["KCMI", UnitSystem -> "Imperial"]
Out[10]=

Version History

  • 1.0.0 – 10 May 2021

Source Metadata

Author Notes

This function relies on Wolfram|Alpha WeatherData which is the same source as Wolfram Language WeatherData but is more flexible and much faster for multiple locations and/or properties.

License Information