Database Reference
In-Depth Information
station['coord']['lat']
station_lon =
station['coord']['lon']
# add the weather station to the
database
AddWeatherStation(station_id,
station_lon, station_lat,
name, temperature)
# first weather station from the
json API response is always the closest
# to the city, so we are grabbing
this temperature and store in the
# temperature field in the cities
PostGIS layer
if station_id ==
stations[0]['id']:
print 'Setting temperature to
%s for city %s' % (
temperature, city_name)
cur2 = conn.cursor()
cur2.execute(
'UPDATE chp08.cities SET
temperature=%s WHERE ogc_fid=%s',
(temperature, ogc_fid))
cur2.close()
# close cursor and close connection to
database
cur.close()
conn.close()
5. Runthe Pythonprogram:
(postgis-cb-env)$ python
get_weather_data.py
Added the PAMR weather station to the
database.
Setting temperature to 268.15 for city
Search WWH ::




Custom Search