Question

I am attempting to get the current weather given a zip code or a set of latitude/longitude coordinates. It appears that best practice to do this (and how NOAA does it) is to get the XML feed for a weather station.

Example: http://www.weather.gov/xml/current_obs/KEDW.xml

The only problem is that NOAA doesn't provide a good way to find the closest weather station given a zip code or coordinates and I did not see any hosted web services out there that will provide this mapping.

Does anyone know of any web services to get the nearest weather station given a zip code or coordinate input? If not, does anyone have any great solutions to look into that provide similar information as NOAA does but takes in a zip code or coordinates?

Was it helpful?

Solution

There are numerous weather APIs out there that will look up the weather based on zip codes, or find the nearest one for a zip code. See this question.

The national weather service has a REST API. CTRL+F for zipcode:

Summarized Data for One or More Zipcodes: Returns DWML-encoded NDFD data for one or more zip codes (50 United States and Puerto Rico).

Here is a sample request


I'm not sure if that one has current conditions. If not, you can use the Wunderground API. First you use GeolookupXML to look up nearby weather stations based on the city (see the nearby_weather_stations element in the sample output), then you can use WXCurrentObXML to get the conditions at one of the weather stations.

OTHER TIPS

It took some searching, but NOAA maintains a list of all the METAR weather stations, with their latitude and longitude coordinates, as well as direct links to their RSS and XML feed URLs. The list is stored in XML here: http://www.weather.gov/xml/current_obs/index.xml

You could use Google's or Yahoo's geocoding APIs to lookup the latitude/longitude of a place name (City, Address, Zipcode, etc.) and then search the weather stations list for the closest METAR station to the given location.

i tried your link and instead of City, Street inputed my zip code. It returned the correct location and weather report. It's possible that it's just a poorly-documented API and a city/street parameter replaced with a 5-digit zip will indeed do what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top