O'Reilly logo

Learning Geospatial Analysis with Python - Second Edition by Joel Lawhead

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving weather data

Next, we will retrieve our final data element: the weather. As mentioned earlier, we will use the WeatherUnderground service that allows us to gather historical weather reports for any place in the world. The weather API is REST-based and JSON-based, so we'll use the urllib module to request the data and the JSON library to parse it. Note that in this section, we cache the data locally so that you can run the script offline to test, if need be. Early on in this section is where you place your WeatherUnderground API key that is flagged by the text, YOUR KEY HERE:

log.info("Creating weather summary") # Get the bounding box centroid for georeferencing weather data centx = minx + ((maxx-minx)/2) centy = miny + ((maxy-miny)/2) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required