Weather reports via XML: Difference between revisions
Brian Wilson (talk | contribs) mNo edit summary |
Brian Wilson (talk | contribs) mNo edit summary |
||
Line 1: | Line 1: | ||
== Forecasts == | |||
You can get regional information in a nice web format from | You can get regional information in a nice web format from | ||
http://www.nws.noaa.gov/ but if you want to insert just the | http://www.nws.noaa.gov/ but if you want to insert just the | ||
Line 35: | Line 37: | ||
</iframe> | </iframe> | ||
</html> | </html> | ||
== Current conditions == | |||
The above shows forecasts. | The above shows forecasts. | ||
I still want to collect current conditions data from the National Weather Service, so that I can plot the information in Cricket graphs. To do this I need to write a cricket 'collector' script. This is a piece of glue that will parse the XML and output simple numbers that can then be inserted into the Cricket RRD database. | I still want to collect current conditions data from the National Weather Service, so that I can plot the information in Cricket graphs. To do this I need to write a cricket 'collector' script. This is a piece of glue that will parse the XML and output simple numbers that can then be inserted into the Cricket RRD database. | ||
Heading back to the NWS site, I see I can get observations in RSS and XML format. | |||
RSS: http://www.weather.gov/data/current_obs/KCVO.rss <br> | |||
XML: http://www.weather.gov/data/current_obs/KCVO.xml | |||
The RSS version is for insertion into a web page, the XML version | |||
is more like raw data -- for logging to a database, this is what I want. | |||
I want to collect visibility, temperature, precipitation, barometric pressure, dew point, humidity, wind speed and direction. | I want to collect visibility, temperature, precipitation, barometric pressure, dew point, humidity, wind speed and direction. |
Revision as of 04:46, 4 December 2005
Forecasts
You can get regional information in a nice web format from http://www.nws.noaa.gov/ but if you want to insert just the information you want into a web page, you can grab the XML data and parse that. They can provide you with tabular data if you don't want to do any programming.
Visit the NWS web site, click on the map to find the area of interest,
Click on "New products" and you will get a form to fill out to select your area and the parameters you want for your feed. Here is the URL that it gave me:
After thinking for a bit I realize that there is no need to do "programming", all I need to do is create a style sheet and insert the code into the page in an iframe:
Here is the iframe code for my location:
<iframe name="Corvallis weather" src="http://ifps.wrh.noaa.gov/cgi-bin/dwf?outFormat=xml&duration=72hr&interval=6&citylist=CORVALLIS%2C44.5710%2C-123.2760&city=Go&latitude=&longitude=&ZOOMLEVEL=1&XSTART=&YSTART=&XC=&YC=&X=&Y=&siteID=PQR" scrolling=no width=480>Sorry, your browser does not support iframes.
Without the stylesheet it will look like this:
<html>
<iframe name="Corvallis weather" src="http://ifps.wrh.noaa.gov/cgi-bin/dwf?outFormat=xml&duration=72hr&interval=6&citylist=CORVALLIS%2C44.5710%2C-123.2760&city=Go&latitude=&longitude=&ZOOMLEVEL=1&XSTART=&YSTART=&XC=&YC=&X=&Y=&siteID=PQR" scrolling=no width=480>Sorry, your browser does not support iframes.
</iframe>
</html>
With styles
<html>
<style type="text/css">
period { color: blue}
</style>
<iframe name="Corvallis weather" src="http://ifps.wrh.noaa.gov/cgi-bin/dwf?outFormat=xml&duration=72hr&interval=6&citylist=CORVALLIS%2C44.5710%2C-123.2760&city=Go&latitude=&longitude=&ZOOMLEVEL=1&XSTART=&YSTART=&XC=&YC=&X=&Y=&siteID=PQR" scrolling=no width=480>Sorry, your browser does not support iframes.
</iframe>
</html>
Current conditions
The above shows forecasts. I still want to collect current conditions data from the National Weather Service, so that I can plot the information in Cricket graphs. To do this I need to write a cricket 'collector' script. This is a piece of glue that will parse the XML and output simple numbers that can then be inserted into the Cricket RRD database.
Heading back to the NWS site, I see I can get observations in RSS and XML format.
RSS: http://www.weather.gov/data/current_obs/KCVO.rss
XML: http://www.weather.gov/data/current_obs/KCVO.xml
The RSS version is for insertion into a web page, the XML version is more like raw data -- for logging to a database, this is what I want.
I want to collect visibility, temperature, precipitation, barometric pressure, dew point, humidity, wind speed and direction.