Get Weather information using Yql query lat,long parms

2.6k views Asked by At

I am using the following YQL query to get weather information

http://query.yahooapis.com/v1/public/yql?q=select%20item%20from%20weather.forecast%20where%20location%3D%2248907%22&format=json

Is there any way to get weather information using longitude, latitude as YQL query parameter.

3

There are 3 answers

3
salathe On BEST ANSWER

You could use a sub-select to go from a latitude/longitude pair to a WOEID like

SELECT * FROM weather.woeid 
WHERE w IN (
    SELECT place.woeid 
    FROM flickr.places(1) 
    WHERE (lat,lon) in (55.948503,-3.198931)
);

(Try in YQL console)

0
Vladyslav Ulianytskyi On

This works for me:

...

query = "SELECT * FROM weather.forecast " +
            "WHERE woeid in (" +
            "SELECT woeid " +
            "FROM geo.places(1) " +
            "WHERE text=\"(%1$s,  %2$s)\") " +
            "AND u='c'";

... and then:

query = String.format(query, location.getLatitude(), location.getLongitude());
0
Anoop P S On

I have found some thing use ful; if you need to forcast weather yql use the SELECT * FROM weather.bylocation WHERE location='Indonesia' select * from weather.forecast where location=90210