Posts Tagged ‘YQL’

GeoPlanet In The Real World

Wednesday, January 21st, 2009

In June of 2008 we launched GeoPlanet, our open, permanent and intelligent infrastructure for geo-referencing data on the Internet, on this blog and a lot of people wrote to us to say they liked it a lot. Some eight months later and GeoPlanet is being used in a wide range of differing ways. Here’s just a sample to re-whet your appetite …

Jim Hamilton seems to like GeoPlanet; so much so that he’s produced three mashups which exercise the power of the GeoPlanet API.

yplaces1First up is YPlaces, which was written primarily to explore the scope of the GeoPlanet API and which offers a visual way of exploring the key concepts of GeoPlanet. Enter a place name and YPlaces will show a map of the place and its coordinates. You can then view the siblings, the children, the neighbours and the belongs-to of your chosen place, all of which are clickable and update the map.

zyp1Then there’s Zyp, a mashup of US ZIP codes, GeoPlanet, Google reverse geocoding, ZIP and county polygons and a dash of Virtual Earth. Entering a place will display a list of possible disambiguations. Select one and you can query GeoPlanet to view output the of GeoPlanet place, children, siblings and neighbours functions.

sakmap1Finally, there’s SakMap, which Jim calls the Swiss Army Knife of maps (SAK … Swiss Army Knife … get it?). The centre point of a map is reverse geocoded and the resultant city name is handed to GeoPlanet which looks up the WOEIDs of the child places, each of which can be viewed. You can also get weather reports for the current place, view an alternate map rendition via Microsoft Virtual Earth, get news, video and pictures via Flickr and even do a web search based on the place name.

All of Jim’s mashups show off the various features of GeoPlanet and it’d be great if the scope of these mashups could be extended outside of the US, such as to Europe or Asia.

boundaries1In October 2008, our friends at Flickr released shape files via the Flickr API. About a month later and Tom Taylor used this new API to produce Boundaries which helps you visualise the shape data. Type in a place name and the GeoPlanet API is used to work out the place’s neighbours and display them boldly and elegantly on a map.

headconference1Also in October 2008, <head> staged a web conference on topics such as web development, Flash, accessibility and web standards that took place entirely online. You could customise the schedule to display in your local time zone; clicking on a map for your location reverse geocoded the place, used GeoPlanet to lookup the time zone for that place and then used the Olson database to display the schedule relative to you time zone. This meant that people in London got a uniquely customised and relevant experience, as did people all over the world.

This is a pretty unique use of GeoPlanet; it’s a mashup but one which happens behind the scenes without most people being aware of it, so much credit should go to the authors of the site who took the time to call out the web APIs used.

Last year on this blog, we wrote about the way in which GeoPlanet had been integrated into YQL, the Yahoo! Query Language. Yahoo! Flash and Flex developer Zach Graves provides a real world tutorial on how to use YQL with Yahoo! Weather. One of the challenges that Zach encountered was converting potentially ambiguous locations into a more structured and canonical format; by using the GeoPlanet API integrated into YQL has was able to normalise place names and pass them straight into the Yahoo! Weather API.

We’re always on the lookout for other uses of GeoPlanet; if you know of one then let us know about it; the best place to do this is through the Applications & Demos GeoPlanet Forum.

Gary Gale, Head of UK Engineering, Yahoo! Geo Technologies

Yahoo! GeoPlanet and YQL

Friday, November 21st, 2008

On October 28, 2008, Yahoo! announced the launch of several components of the Yahoo! Open Strategy (Y!OS). Among these was the Yahoo! Query Language (YQL), a web service that enables developers to query, filter, and combine data across multiple Yahoo! web services using a SQL-like syntax. The GeoPlanet Web Service has been integrated into YQL, allowing users to take advantage of place in a number of different ways. Web Services that return place names can be used to generate WOEIDs. The GeoPlanet Web Service can be used to get place names needed by other web services from WOEIDs. The possibilities are endless!

A great place to start exploring YQL is the YQL Console. This web application allows developers to experiment with YQL queries and create URLs they can then embed in their own web applications. More information about YQL is available on the Yahoo! Developer Network YQL website.

YQL in a nutshell

YQL represents web service collections as tables with primary and secondary keys representing collection filters and data fields representing each of the collection’s response elements. The YQL DESC verb describes a table, including its primary key, other supported input fields, the output fields, and an example query. The YQL SELECT verb selects specific data fields (response elements) from a table (collection) using a key (filter).

GeoPlanet collections and resources are represented by eight YQL tables.

Collection Table
/places geo.places
/place geo.places
/place/…/ancestors geo.places.ancestors
/place/…/belongtos geo.places.belongtos
/place/…/children geo.places.children
/place/…/neighbors geo.places.neighbors
/place/…/parent geo.places.parent
/place/…/siblings geo.places.siblings
/placetypes geo.placetypes

Examples

The following are some examples showing how information from GeoPlanet can be generated using YQL and used in various ways. The basic examples use only the geo tables to return data. The intermediate examples combine various geo tables to return data. The advanced examples combine geo data with data from other Yahoo! web services.

Basics

Learn about the geo.places table
desc geo.places
Determine the WOEID for a place (e.g. SFO)
select woeid from geo.places where text = "SFO"
Determine the name of a place known by its WOEID
select name from geo.places where woeid = 12521721
Determine the name of the country a place is located in (e.g. Sunnyvale, CA)
select country from geo.places where text = "Sunnyvale, CA"

Intermediate

Return just place name and place type name for administrative areas containing a place (Sunnyvale, CA)
select name,placeTypeName from geo.places.ancestors where descendant_woeid in (select woeid from geo.places where text="Sunnyvale, CA")
Determine the timezone of a place (e.g. SFO)
select name from geo.places.belongtos where member_woeid in (select woeid from geo.places where text = "SFO") and placetype = "Time Zone"
Determine the names of neighboring places (e.g. Sunnyvale, CA)
select name from geo.places.neighbors where neighbor_woeid in (select woeid from geo.places where text = "Sunnyvale, CA")
Determine the Zip Codes in a town (e.g. Sunnyvale, CA)
select name from geo.places.children where parent_woeid in (select woeid from geo.places where text = "Sunnyvale, CA") and placetype = "Postal Code"

Advanced

Determine the WOEID for a user (e.g. me)
select woeid from geo.places where text in (select location from social.profile where guid = me)
Determine the timezone for a user (e.g. me)
select name from geo.places.belongtos where member_woeid in (select woeid from geo.places where text in (select location from social.profile where guid = me)) and placetype = "Time Zone"
Get weather forecast for a specific place known by its WOEID
select item.description from weather.forecast where location in (select postal from geo.places where woeid = 12797568)

Summary

YQL is a powerful tool that combines and filters the data provided by many Yahoo! web services in a form that allows developers already familiar with SQL to be productive quickly and effectively. By integrating GeoPlanet with YQL, Yahoo! Geo Technologies has added the value of GeoPlanet’s geo-permanent named place management system to an already powerful service.

Eddie Babcock, Yahoo! Geo Technologies