Weather reports via XML

From Wildsong
Revision as of 04:36, 4 December 2005 by Brian Wilson (talk | contribs)
Jump to navigationJump to search

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.