NOAA’s Weather Feeds
Posted by Stephen on September 25, 2006 in Programming, Stuff
For a project at work, I need to provide a constantly-updated weather forecast of a certain area in Northern Minnesota. I was pleasantly surprised to learn that The National Weather Service provides this information for free in XML format. Unfortunately, accessing it is kind of a pain. I would like to be able to do something like this:
wget http://nws.noaa.gov/feeds/?zip=55xxx&days=7
But that would be too easy. Instead, you have to use SOAP to send a request and get a response. Even in Ruby, it’s more work and doesn’t really seem natural:
#!/opt/local/bin/ruby
require 'soap/wsdlDriver.rb'
WSDL_URL = "Really long URL"
latitude = 47.716309
longitude = -90.489143
soap = SOAP::WSDLDriverFactory.new(WSDL_URL).create_rpc_driver
xml = soap.NDFDgenByDay(latitude, longitude,
Time.now.strftime("%Y-%m-%d"),
7, "24 hourly")
File.open("/path/to/data/weather.xml", "w") do |file|
file << xml
end
On the bright side, kudos to Ruby for including SOAP classes in its standard library. Python doesn’t seem to do this, and the Python SOAP module in DarwinPorts wouldn’t build for some reason.
Write a Comment on NOAA’s Weather Feeds
Comments on NOAA’s Weather Feeds are now closed.