Weather reports via XML: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
 
Brian Wilson (talk | contribs)
mNo edit summary
Line 18: Line 18:
Here is the iframe code for my location:
Here is the iframe code for my location:
<pre>
<pre>
<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>
<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.
</pre>
</pre>


Without the stylesheet it will look like this:<br>
Without the stylesheet it will look like this:<br>
<html>
<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>
<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>
</iframe>
</html>
</html>
With styles<br>
<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>
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 want to collect visibility, temperature, precipitation, barometric pressure, dew point, humidity, wind speed and direction.

Revision as of 04:36, 4 December 2005

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:

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

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>

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 want to collect visibility, temperature, precipitation, barometric pressure, dew point, humidity, wind speed and direction.