...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import requests import json sensor_id = 22 api_server = r"https://greatlakestogulf.org/geostreams" output_directory = r"downloads" user = {'identifier': '***email***', 'password': '***password***'} r = requests.post(api_server + '/api/authenticate', data=json.dumps(user), headers={'Content-Type': 'application/json'}) print("Authentication status:", r.status_code, "for", api_server) headers = {"x-auth-token": r.headers["x-auth-token"], "Content-Encoding": "application/json"} route = api_server + "/api/datapoints?sensor_id=" + str(sensor_id) + "&format=csv" r = requests.get(route, headers=headers) with open(output_directory + '/datapoints_sensor_' + str(sensor_id) + '.csv', 'w') as f: f.write(r.text) print("Route: " + route) print("Request Status:", str(r.status_code)) print("Datapoint JSON saved to " + output_directory + '/datapoints_sensor_' + str(sensor_id) + '.csv') |
Using Python Library (pyGeotemporal)
Install pyGeotemporal
It is recommended to use a virtual environment for python.
Code Block | ||
---|---|---|
| ||
git clone ssh://git@opensource.ncsa.illinois.edu:7999/geod/pygeotemporal.git
cd pygeotemporal
python setup.py install |
<< insert code example here>>
<< need to have instruction how to get pyGeotemporal >>
Jupyter Notebook
Jupyter notebook example can be download here geostreams_jupyter.ipynb
...