Worksheet – mapping the weather _ raspberry pi learning resources

One thousand Weather Stations were sent out to schools all over the world at the beginning of 2016, ready to be assembled and begin collecting global weather data.

The Weather Stations continually monitor the weather and then send their data to an Oracle database, where it is stored and from which it can be accessed.

You can then look at gathering some data from all the available Weather Stations and plotting that weather data to the map. Data recovery pro Fetching the weather stations

For greater detail on using JSON and the RESTful API of the Raspberry Pi Weather Station database, you can have a look over the resources – Fetching the Weather and Graphing the Weather.

To begin with you’ll need to import a few Python modules.


Data recovery tools mac If you haven’t installed them yet, you can find details on the requirements page. Z wave database from requests import get

Here, requests is used to fetch the json data from the database, json is used to process JSON data. Database orm Basemap is a tool for creating maps in Python, and matplotlib allows the plotting of points to the map.

Next, the URL for the RESTful API needs to be stored as a string in your program. Database workbench url = ‘https://apex.oracle.com/pls/apex/raspberrypi/weatherstation/getallstations’

You should see something like this printed out in the shell: {‘weather_stn_name’: ‘Pi Towers Demo’, ‘weather_stn_id’: 255541, ‘weather_stn_long’: 0.110421, ‘weather_stn_lat’: 52.213842}

This is the first record in the JSON data. Database best practices As you can see, the station’s longitude and latitude are within the dictionary. Database schema If you want to learn a little more about longitudes and latitudes, then have a look at the second worksheet from Fetching the Weather These are easy enough to access. Data recovery external hard drive For instance, you could type this into the shell: stations[‘items’][0][‘weather_stn_long’]

Two list comprehensions can be used in your Python file to fetch all the longitude and latitude values. Database 1 to many These iterate over the JSON data and extract each of the longitudes and latitudes and place them in separate lists. Data recovery galaxy s6 lons = [station[‘weather_stn_long’] for station in stations[‘items’]]

To begin, you can define where your map will be centred. Os x data recovery software For the purposes of this resource, the code will reflect a centre that is on the intersection of the Prime Meridian and the Equator: longitude 0 and latitude 0. Database technology You could centre your map at the longitude and latitude of your own location if you prefer. Database queries definition cc_lat = 0

To finish off drawing a basic map, you need two more lines. Data recovery mac free The first will draw the coastlines of all the continents and the second will render the map. Data recovery phone my_map.drawcoastlines()

First of all, have a play with the different projections that are available in the Basemap module. Database normalization There’s a list of them below. Data recovery quote Basemap syntax

Now that you have the map, the way you like it, you can plot all the locations of the Weather Wtations. Database key types These lines need to go before the plt.show() line. Database instance x,y = my_map(lons, lats)

• Lastly, if you want to focus on a specific part of the map, you can set the longitude and latitude of the upper right and lower left corners. Data recovery raid 0 Here the map is centred on the UK, with additions and subtractions made to the centre position to position the corners.

banner