I am trying to write a script that returns just a persons village, town or city. I am using the following YQL query, but the results from the console are too specific, they give me the neighbourhood first.
select * from flickr.places where lat=51.558418 and lon=-1.781985 and api_key=YOU_FLICKR_API_KEY
Here is the results of my query from the console.
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng"
yahoo:count="1" yahoo:created="2011-10-25T09:35:50Z" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-start-time="1" execution-stop-time="123" execution-time="122"><![CDATA[http://api.flickr.com/services/rest/?method=flickr.places.findByLatLon&lat=51.558418&lon=-1.781985]]></url>
<user-time>124</user-time>
<service-time>122</service-time>
<build-version>22535</build-version>
</diagnostics>
<results>
<places accuracy="16" latitude="51.558418" longitude="-1.781985" total="1">
<place latitude="51.547" longitude="-1.802"
name="West Leaze, Swindon, England, GB, United Kingdom"
place_id="sddCvK9SW703gg" place_type="neighbourhood"
place_type_id="22"
place_url="/United+Kingdom/England/Swindon/West+Leaze"
timezone="Europe/London" woeid="39722"/>
</places>
</results>
</query>
I want to be able to change the place_type_id in the query. I know I could use regex to isolate the info, but I am not sure if that will work for all locations so I would much prefer to have the API just returning my desired result.
Flickr’s
flickr.places.findByLatLonmethod, which is being called in the background by your YQL query, accepts anaccuracykey.See » Flickr docs for
flickr.places.FindByLatLon.Putting that to use is as simple as providing
accuracy =nin yourwhereclause. A value of around 10 looks to be about the accuracy that you are looking for, but experiment to see what is best.Aside
Documentation for the data sources / services being used by YQL tables can generally be obtained by looking at the table description.
This gives lots of information, usually including at least one link to documentation pages. See the
metasection for thedocumentationURLitems.