Finding the Current Temperature

Open Weather Map

Open Weather Map provides an API for returning weather information in JSON or XML format.

A query requesting the current temperature in Iowa City format is XML format would would use a URL of the form

https://api.openweathermap.org/data/2.5/weather?q=Iowa+City,IA&mode=xml&appid=key

or

https://api.openweathermap.org/data/2.5/weather?lat=41.66&lon=-91.53&mode=xml&appid=key

with key replaced by your API key (free, but requires registration).

Here is a simple function to obtain the current temperature for from Open Weather Map based on latitude and longitude:

library(xml2)
findTempOWM <- function(lat, lon) {
    base <- "https://api.openweathermap.org/data/2.5/weather"
    url <- sprintf("%s?lat=%f&lon=%f&mode=xml&units=Imperial&appid=%s",
                   base, lat, lon, OWMkey)
    page <- read_xml(url)
    as.numeric(xml_text(xml_find_first(page, "//temperature/@value")))
}

For Iowa City you would use

findTempOWM(41.7, -91.5)

This function should be robust since the format of the response is documented and should not change.

Using commercial web services should be done with care as there are typically limitations and license terms to be considered.

They may also come and go: Google’s API was shut down in 2012.

National Weather Service

The National Weather Service provides a site that produces forecasts in a web page for a URL like this:

http://forecast.weather.gov/zipcity.php?inputstring=Iowa+City,IA

This function uses the National Weather Service site to find the current temperature by parsing the HTML data in the response:

findTempGov <- function(citystate) {
    url <- paste("http://forecast.weather.gov/zipcity.php?inputstring",
                 url_escape(citystate),
                 sep = "=")
    page <- read_html(url)
    xpath <- "//p[@class=\"myforecast-current-lrg\"]"
    tempNode <- xml_find_first(page, xpath)
    nodeText <- xml_text(tempNode)
    as.numeric(sub("([-+]?[[:digit:]]+).*", "\\1", nodeText))
}

For Iowa City you can use

findTempGov("Iowa City, IA")

This will need to be revised whenever the format of the page changes, as happened sometime in 2012.

Murrell’s Data Technologies book discusses XML, XPATH queries, regular expressions, and how to work with these in R.

Some other resources for regular expressions:

Recently the server has either been overloaded or modified to reject requests from the same address that are too close together so it is not currently useful for collecting temperatures at multile locations.

The National Weather Service also provides several APIs, including a REST API that returns JSON (XML may be available but didn’t seem to work right for me) that use a url like this:

http://forecast.weather.gov/MapClick.php?lat=41.7&lon=-91.5&FcstType=json

You can read the temperature from this API using the fromJSON function from the jsonlite package:

library(jsonlite)
icurl <-
    "http://forecast.weather.gov/MapClick.php?lat=41.7&lon=-91.5&FcstType=json"
icjson <- fromJSON(icurl)
icjson$currentobservation$Temp

Uncortunately this also seems unreliable at the moment.

Temperatures and Locations for Some Iowa Cities

A small selection of Iowa cities:

places <- c("Ames", "Burlington", "Cedar Rapids", "Clinton",
            "Council Bluffs", "Des Moines", "Dubuque", "Fort Dodge",
            "Iowa City", "Keokuk", "Marshalltown", "Mason City",
            "Newton", "Ottumwa", "Sioux City", "Waterloo")

Currently the OWM API seems most reliable.

To look up temperatures with that API, and to plot them on a map, we need to find the locations of these cities.

We can obtain a file of geocoded cities and read it into R:

if (! file.exists("cities.csv")) {
    download.file("http://www.stat.uiowa.edu/~luke/data/cities.csv.zip",
                  "cities.csv.zip")
    unzip("cities.csv.zip")
}

cities <- read.csv("cities.csv", header = FALSE)
names(cities) <- c("City", "State", "Lat", "Lon")
head(cities)
##           City State      Lat        Lon
## 1      ROBERTS    ID 43.69892 -112.17320
## 2  HODGENVILLE    KY 37.55932  -85.70727
## 3 WILLIAMSPORT    TN 35.72263  -87.21270
## 4       MAUMEE    OH 41.57125  -83.68504
## 5        BERNE    NY 42.60224  -74.15462
## 6     MONCLOVA    OH 41.57725  -83.77238

Select the cities we want and find their temperatures:

library(dplyr)
temploc <- filter(cities, City %in% toupper(places), State == "IA") %>%
    mutate(temp = mapply(findTempOWM, Lat, Lon))
head(temploc)
##           City State      Lat       Lon  temp
## 1   FORT DODGE    IA 42.43860 -94.16659 36.43
## 2    IOWA CITY    IA 41.65789 -91.53309 40.96
## 3 MARSHALLTOWN    IA 42.03610 -92.99887 38.03
## 4 CEDAR RAPIDS    IA 41.97666 -91.67315 41.47
## 5   BURLINGTON    IA 40.89841 -91.16439 44.20
## 6   MASON CITY    IA 43.15272 -93.19944 37.83

Remove any rows with missing temeratures:

temploc <- filter(temploc, ! is.na(temp))

Creating the Map

We can use the borders function from ggplot2 along with geom_text to show the results:

library(ggplot2)
library(ggthemes)
tpoints <- geom_text(aes(x = Lon, y = Lat, label = round(temp)),
                     color = "red",
                     fontface = "bold",
                     data = temploc)

p <- ggplot() +
    borders("county", "iowa") +
    tpoints +
    coord_map() +
    theme_map()

p

To add contours we can use interp from the interp package and the geom_contour function:

library(interp)
surface <- with(temploc, interp(Lon, Lat, temp, linear = FALSE))

srfc <- expand.grid(Lon = surface$x, Lat = surface$y)
srfc$temp <- as.vector(surface$z)
tconts <- geom_contour(aes(x = Lon, y = Lat, z = temp),
                       data = srfc, na.rm = TRUE, bins = 6)

p + tconts + tpoints

The ggmap package provides further map support, including background maps from Google, Stamen, and OpenStreatMap.

library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.

Using Google maps now requires an API key.

Downloading a Stamen map:

maptype <- "terrain"
maptype <- "toner"
map <- get_stamenmap(c(-97.2, 40.4, -89.9, 43.6), zoom = 8, maptype = maptype)

ggmap creates a ggplot object, sets the coordinate system, and makes some theme adjustments:

ggmap(map)

Add the county borders, contours, and temperatures.

ggmap(map) + borders("county", "iowa") + tconts + tpoints

LS0tCnRpdGxlOiAiQ3JlYXRpbmcgYSBDdXJyZW50IFRlbXBlcmF0dXJlIE1hcCIKb3V0cHV0OgogIGh0bWxfZG9jdW1lbnQ6CiAgICB0b2M6IHllcwogICAgY29kZV9kb3dubG9hZDogdHJ1ZQogICAgY29kZV9mb2xkaW5nOiAiaGlkZSIKZGF0ZTogImByIGZvcm1hdChTeXMudGltZSgpLCAnJWQgJUIsICVZICVIOiVNJylgIgotLS0KCmBgYHtyIGdsb2JhbF9vcHRpb25zLCBpbmNsdWRlID0gRkFMU0V9CmtuaXRyOjpvcHRzX2NodW5rJHNldChjb2xsYXBzZSA9IFRSVUUsIGNsYXNzLnNvdXJjZSA9ICJmb2xkLXNob3ciLAogICAgICAgICAgICAgICAgICAgICAgZmlnLmFsaWduID0gImNlbnR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