Rain or Shine Weather API
I’m lucky; if I want to know whether it’s currently raining, I have a highly-tuned mechanism for collecting that information. Using only eyes and a window, my visual processing system is so sophisticated that I usually have an answer within 147 milliseconds.
Sometimes, however, the look-out-window technique is impractical. A few scenarios:
- I don’t have access to a window with an exterior view. (Like in a basement, or an office cubicle, or at Costco.)
- It’s too dark outside to easily tell if that’s a light drizzle or just my neighbor’s sprinkler system.
- My vision is impaired, either by environment or genetics.
- I’m a web server and I don’t have eyes.
I’m particularly interested in that last point. Web servers live in The Cloud but not in my cloud so they can’t tell me its current precipitation status. And I think it would be pretty cool if a web server knew whether it was raining right here, right now.
Exposing that information via some sort of API could enable a lot of fun mashups like reminding me to grab my umbrella, waking me up early in anticipation of the inevitable traffic jam, or connecting to my hypothetical Tesla parked outside and automatically closing its moonroof.
Build a web service that will determine the current precipitation status for a given GPS location. A request like:
GET /rain-or-shine?location=40.6892,-74.0444 HTTP/1.1
will tell me if Lady Liberty needs to button up her copper raincoat:
How might your web service figure out if it’s raining? I’m definitely not a weather expert, but I can get a pretty good idea with a quick glance at a radar map.
So it might just be a matter of finding a reliable source of radar data. The NOAA National Weather Service is a good place to start. (This page, for instance, describes some of the metadata available with their radar imagery.)
The Tricky Bit
If you can find a data source that provides pure radar readings in dBZ, you’re in business.
Things will be a little tougher if you have to decipher map images directly. First, you’ll need to figure out which image to load and deal with lining up the projection correctly to find your input coordinates on the map. Then, you’ll need to interpret the RGB color at that pixel location according to the legend.
As a next step, your web service could track precipitation status over time, perhaps even providing notifications when it is about to start or stop raining. Then I could know exactly when it’s time to make a run for it while all those other losers get caught in the downpour.