Question

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.

Was it helpful?

Solution

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)

OTHER TIPS

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());

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

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