I am curious whether there is some place where one can look up the mapping between actual location and weather station (I assume) acronyms. E.g., what the heck is "KNDZ"?


You can get a latitude and longitude for the weather station and plot a GeoMarker at that location like this

latlon = WeatherData["KNDZ", #] & /@ {"Latitude", "Longitude"};
gp = GeoPosition[latlon];
plot = GeoGraphics[GeoMarker[gp]]

For a full list of properties of the weather station, use WeatherData["KNDZ", "Properties"]

| improve this answer | |
  • 1
    $\begingroup$ More compactly: GeoGraphics[GeoMarker[GeoPosition[WeatherData["KNDZ", "Coordinates"]]]] $\endgroup$ – J. M.'s discontentment Mar 30 '18 at 3:11

You can use the Weather Underground API to look up information that is not present in WeatherData[] (tho you need to register to get an API key):

$WUAPIKey = (* insert API key here *);
SetAttributes[WULookup, Listable];

WULookup[station_] := Module[{s = station, chk, loc, pos, raw},
  If[Head[s] === Entity, s = CommonName[s]];
  raw = Import["http://api.wunderground.com/api/" <> $WUAPIKey <> "/geolookup/q/" <>
               s <> ".json", "RawJSON"];
  chk = Lookup[raw["response"], "error", True];
     {pos, loc} = TakeDrop[Lookup[raw["location"],
                                  {"city", "state", "country_name", "lat", "lon"}], -2];
     GeoGraphics[GeoMarker[GeoPosition[Internal`StringToDouble /@ pos]], 
                 PlotLabel -> Row[DeleteCases[loc, ""], ", "]],
     Failure[chk["type"], chk["description"]]]]

For example:

WULookup[{"AYWK", "BGBW", "CWSS", "KNDZ", "YMES"}] // GraphicsRow

lookup result

| improve this answer | |
  • $\begingroup$ Great pattern for calling a Web API $\endgroup$ – FredrikD Apr 2 '18 at 13:49
  • 1
    $\begingroup$ Mathematica makes it really easy now to use an API whenever the curated data functions are found lacking. It's really awesome. $\endgroup$ – J. M.'s discontentment Apr 2 '18 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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