开发者

YQL: how to get all cities from a country

I want to get all cities from a specify country using YQL. Anybody knows the correct YQL to get all cities from a coun开发者_Python百科try ?

Thanks.


The documentation for this is at http://developer.yahoo.com/geo/geoplanet/guide/yql-tables.html#geo-places-children

However I've played around with this before and it's not as easy as you'd think.

For example you'd expect that a query like select * from geo.places.children where parent_woeid = 23424832 AND type = 'Town' would return all towns in Guam but it doesn't, it returns no results.

Selecting all children of Guam - select * from geo.places.children where parent_woeid = 23424832 gives you the administrative divisions, and from there you can query again to find the children of each admin.

However the world is a very complex place and it's a nightmare trying to do this for all countries as the admin types are different for each.

The best approach I found was to download the Geoplanet data and use the parent WOEIDs to work out the relationships, you can download it from here - http://developer.yahoo.com/geo/geoplanet/data/


You can't download data updates anymore. Alternatively you have to drill down to administrative levels (depends on the country you choose - usually a county (not country) woeid is enough) and use the following model for your queries:

http://query.yahooapis.com/v1/public/yql?q=select+*+from+geo.places.descendants+where+ancestor_woeid={yourcountywoeid}+and+placetype='Town'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜