Feb 11, 2009

Import water data from National Weather Service

Besides real-time water data from USGS in the previous post, we like to import more data from National Weather Service, it has the forecast data on water stage.

The data is distributed in XML format.


(* function to extract data from xml *)

groupdata /. {x_,y_,z_}:> {StringReplace[StringDrop[x,-9],{"T"->" "}],ToExpression[y],ToExpression[z]*1000}];

(* extract data*)

observeddata = extractdata[NWSxml, "observed"];
forecastdata = extractdata[NWSxml, "forecast"];

(* produce the graph *)


Flood stage is at 11.0 feet, it seems the white river may be in the flood stage in next several days.

1 comment:

Dem_z said...

Tried running. Get an error --

PS LOVE YOUR BLOG. Post more, will be an avid reader!!

NWSxml = Import[http : // www.crh.noaa.gov/ahps2/xml/nori3_hgirg.xml];

Syntax::sntxf: "http:" cannot be followed by "//www.crh.noaa.gov/ahps2/xml/nori3_hgirg.xml".

Syntax::tsntxi: "http:" is incomplete; more input is needed.

Syntax::sntxi: Incomplete expression; more input is needed.