0
$\begingroup$

I would like to get historical monthly precipitation for all U.S. states.

However, WeatherData fails for some U.S. states and works for others.

Why is this?

Is there another way to get this data?

Screenshot of the problem and code below:

enter image description here

WeatherData[
 "Iowa",
 "TotalPrecipitation",
 {
  {1988, 06, 01},
  {1989, 06, 30},
  "Month"
  }
 ]

WeatherData[
 "Nebraska",
 "TotalPrecipitation",
 {
  {1988, 06, 01},
  {1989, 06, 30},
  "Month"
  }
 ]

When I try to list of entities as suggested by the error message using WeatherData[] I see that neither state is in the entity list:

MemberQ[wd, "Iowa"] (* False *)
MemberQ[wd, "Nebraska"] (* False *)
$\endgroup$

1 Answer 1

2
$\begingroup$
$Version

(* "13.3.0 for Mac OS X ARM (64-bit) (June 3, 2023)" *)

Clear["Global`*"]

Represent the states by the appropriate Entity

states = EntityList[
   EntityClass["AdministrativeDivision", "AllUSStatesPlusDC"]];

data = {#, 
     WeatherData[#, 
      "TotalPrecipitation", {{1988, 06, 01}, {1989, 06, 30}, "Month"}]} & /@ 
   states;

enter image description here

Length@states

(* 51 *)

Count[data, TimeSeries, {0, Infinity}]

(* 51 *)

Select[data, #[[1]] === 
  Entity["AdministrativeDivision", {"Nebraska", "UnitedStates"}] &]

enter image description here

Or use a city

WeatherData["Omaha", "TotalPrecipitation", {{1988, 06, 01}, {1989, 06,
    30}, "Month"}]

enter image description here

$\endgroup$
2
  • 1
    $\begingroup$ Thanks for the workaround. From the message in your ouput I note in the docs that "The location can also be given as {lat,long}, or a city specification is given of the type used in CityData, in which case WeatherData[loc,[Ellipsis]] gives results for the nearest high-reliability weather station." Does this imply that instead of state TotalPrecipitaion we are just getting the data from one weather station? $\endgroup$ Jul 10, 2023 at 6:37
  • 1
    $\begingroup$ I would infer that but I don’t know. $\endgroup$
    – Bob Hanlon
    Jul 10, 2023 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.