Yahoo Weather Query by Latitude and Longitude
Asked Answered
N

2

10

I want to fetch some weather data via latitude and longitude using yahoo query. but it seems this query is not available now. the query is below:

select * from weather.forecast where woeid in (SELECT woeid FROM geo.placefinder WHERE text="{lat},{lon}" and gflags="R")

is this query is changed to new one or something? or it didn't exist anymore? last time I use this format was about 2 months ago and it worked well. but now it can't fetch any data. result from YQL console is as below:

{
 "error": {
  "lang": "en-US",
  "description": "Tenant 'query_yahooapis_com' access to 'Resource [tenantName=query_yahooapis_com, type=TABLE, name=geo.placefinder, locatorType=FILE, url=/home/y/share/manhattan/application/tenantBundles/yql_query_yahooapis_com_manhattan_v2/YQL-INF/restdefs/geo.placefinder.xml, useUrl=false]' is denied."
 }
}

I already make some research, including this post: How to get Yahoo's woeid by location?

Is that true that yahoo already terminate this latitude longitude query for fetching weather?

Northrup answered 5/2, 2016 at 9:22 Comment(0)
G
22

According to the latest reply to this answer, you should switch to the table geo.places and remove the gflags="R" part. I tried it in the YQL console and it seems to work:

select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(latitude,longitude)")
Gainly answered 17/2, 2016 at 10:54 Comment(5)
hi. thank you for reply. but seems your answer still produce the same result. i really think that this query is not valid anymore.Northrup
It doesn't produce the same results. I don't know how you tried it, but I just tried and everything works fine. take a look here and just press the test buttonGainly
may i know, what the exact location you put, i mean the latitude and longitude that you are using for this query? yes i already try your test and it works. but it seems you only put 'lat' and 'lon' in the query.Northrup
Try this one, is New York: select * from weather.forecast where woeid in (SELECT woeid FROM geo.places WHERE text="(40.7141667,-74.0063889)")Gainly
If this answer has been useful, could you please vote this? I suppose it's you that gave the answer a negative vote...Gainly
H
1

This works for me(you should switch to the table geo.places(1)):

...

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());
Hellman answered 1/8, 2018 at 11:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.