Guam or Guatemala?

  • 1
  • Question
  • Updated 5 years ago
The Country to ISO matching table has two GU entries in the Wunderground Code column. One maps to ISO Code GU (Guam) whereas the other maps to the ISO Code GT (Guatemala). So when the API returns GU as the country, what do I do?

In a similar situation, there are two AU entries in the Wunderground Code column. However, both map to ISO Code AU (Australia). So there is no ambiguity here, just a confusing double entry.

Finally, there are Wunderground Code that have no corresponding ISO Code, such as TB, which has been identified as Tibet in another topic. How are we supposed to glean the Country name from the Wunderground Codes in these cases?
Photo of John Belmonte

John Belmonte

  • 18 Posts
  • 1 Reply Like

Posted 5 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
Driven by curiosity, made some research myself too.

First, according to Guam scenario, published table, Weather Underground database table, the whole madness, etc. I think that Country to ISO Matching WUAPI table should publish for Guam the US_GU value.

For those needing to match to ISO (even if some features return ISO 3166 keys like geolookup provides country_iso3166) a query for Hagåtña reveals the true returned key for country value.


{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"geolookup": 1
}
}
, "location": {
"type":"CITY",
"country":"US_GU",
"country_iso3166":"GU",
"country_name":"US_GU",
"state":"",
"city":"Hagåtña",
"tz_short":"ChST",
"tz_long":"Pacific/Guam",
"lat":"13.483333",
"lon":"144.750000",
"zip":"96910",
"magic":"1",
"wmo":"99999",
"l":"/q/zmw:96910.1.99999",
"requesturl":"US//Agana_Heights.html",
"wuiurl":"http://www.wunderground.com/US//Agana_Heights.html",
"nearby_weather_stations": {
"airport": {
"station": [
{ "city":"", "state":"", "country":"", "icao":"", "lat":"", "lon":"" }
,{ "city":"Guam Agana", "state":"GU", "country":"US", "icao":"PGUM", "lat":"13.48340034", "lon":"144.79600525" }
,{ "city":"Andersen AFB", "state":"GU", "country":"US", "icao":"PGUA", "lat":"13.58395290", "lon":"144.93002319" }
,{ "city":"Rota", "state":"MP", "country":"US", "icao":"PGRO", "lat":"14.17430782", "lon":"145.24253845" }
]
}
,
"pws": {
"station": [
{
"neighborhood":"Maite",
"city":"Maite",
"state":"GU",
"country":"US",
"id":"KGUMAITE2",
"lat":13.476530,
"lon":144.762390,
"distance_km":1,
"distance_mi":0
},
{
"neighborhood":"Perezville",
"city":"Tamuning, Guam",
"state":"GU",
"country":"Guam",
"id":"KGUTAMUN1",
"lat":13.503200,
"lon":144.776794,
"distance_km":3,
"distance_mi":2
},
{
"neighborhood":"Ordot Dump",
"city":"Guam",
"state":"",
"country":"GUAM",
"id":"IGUAM3",
"lat":13.440602,
"lon":144.751770,
"distance_km":4,
"distance_mi":2
},
{
"neighborhood":"Mangilao",
"city":"Mangilao",
"state":"GU",
"country":"US",
"id":"KGUMANGI2",
"lat":13.467694,
"lon":144.831543,
"distance_km":8,
"distance_mi":5
},
{
"neighborhood":"Jeffs Pirates Cove, Guam",
"city":"Ipan Talofofo",
"state":"GU",
"country":"US",
"id":"KGUIPANT1",
"lat":13.364830,
"lon":144.769501,
"distance_km":13,
"distance_mi":8
}
]
}
}
}
}


so, for a similar response, Guatemala City has GU for country key in returned data



{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"geolookup": 1
}
}
, "location": {
"type":"INTLCITY",
"country":"GU",
"country_iso3166":"GT",
"country_name":"Guatemala",
"state":"",
"city":"Guatemala City",
"tz_short":"CST",
"tz_long":"America/Guatemala",
"lat":"14.610000",
"lon":"-90.530000",
"zip":"00000",
"magic":"1",
"wmo":"78641",
"l":"/q/zmw:00000.1.78641",
"requesturl":"global/stations/78641.html",
"wuiurl":"http://www.wunderground.com/global/stations/78641.html",
"nearby_weather_stations": {
"airport": {
"station": [
{ "city":"Guatemala Aeropuertola Aurora", "state":"", "country":"Guatemala", "icao":"MGGT", "lat":"14.58329964", "lon":"-90.52749634" }
,{ "city":"Guatemala", "state":"", "country":"GU", "icao":"MGGT", "lat":"14.58329964", "lon":"-90.52749634" }
]
}
,
"pws": {
"station": [
{
"neighborhood":"Zona 12",
"city":"Guatemala",
"state":"Guatemala",
"country":"Guatemala",
"id":"IGUATEMA9",
"lat":14.577063,
"lon":-90.563301,
"distance_km":5,
"distance_mi":3
},
{
"neighborhood":"Acatan zona 16",
"city":"Guatemala",
"state":"Guatemala",
"country":"Guatemala",
"id":"IGUATEMA15",
"lat":14.610993,
"lon":-90.470634,
"distance_km":6,
"distance_mi":3
},
{
"neighborhood":"Casa Aleluya",
"city":"San Bartolome",
"state":"Guatemala",
"country":"GUATEMALA",
"id":"ISANTIAG11",
"lat":14.615229,
"lon":-90.680595,
"distance_km":16,
"distance_mi":9
}
]
}
}
}
}


Following above preamble, a resolute answer to the " So when the API returns GU as the country, what do I do?" question can be "Handle data as relating to a Guatemala city".

Since I don't really like how the documentation evolved and how its poorly maintained, I think the same approach can be used for similar discovered ambiguities, including other country-code mismatches.