开发者

How to Get Current Weather via Web Services [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 6 years ago.

Improve this 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 ha开发者_Python百科ve any great solutions to look into that provide similar information as NOAA does but takes in a zip code or coordinates?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜