The previous version of the ShowPix app used a bounding box to look for geotagged photos (see Searching Time & Place by Interestingness on Flickr). But if you want to search within a political boundary, most of the time a rectangle won’t be a good fit. The Flickr API offers two solutions, both in the flickr.photos.search method: woe_id (where-on-Earth identifier) and place_id.

The place ID codes are used only within Flickr, while WOE ID codes are supported by Yahoo! Geo Technologies. (Flickr was founded in 2004, and bought by Yahoo in 2005.) So, I’m going to play with WOE ID codes since they can be reused by applications other than Flickr. Yahoo has a Key Concepts page that explains how WOE IDs work.

The app now accepts WOE IDs in place of the bounding box, which significantly shortens the URL. But first you need to find the WOE ID to use in the call. One place to start is Flickr’s Geo API Explorer, which starts off with the parent (or should I say, mother) of all other places, the Earth itself, which unsurprisingly has a code of 1.

Each geotagged photo on Flickr has up to 5 levels of place:

  • neighbourhood
  • locality (in the USA, a city)
  • county
  • region (in the USA, a state)
  • country

Santa and His Favorite ElfI use the flickr.photos.geo.getLocation method to get the geographic data for a given photo (providing the photo_id). For example, the photo on the right returns the following:

  • neighbourhood: Logan Circle (WOE ID: 2441121)
  • locality: Washington (WOE ID: 2514815)
  • county: District of Columbia (WOE ID: 12587802)
  • region: District of Columbia (WOE ID: 2347567)
  • country: United States (WOE ID: 23424977)

The neighborhood (note the API uses the British spelling) is often wrong. This photo was taken in Adams Morgan, not Logan Circle, which doesn’t even share a border with Adams Morgan. And oddly the Flickr page states “This photo was taken … in Lanier Heights, Washington, DC.” Lanier Heights is a seldom-used name for an area within what most folks would consider Adams Morgan. Not sure how Flickr selects the location name used in the main page.

Washington, DC has its own inherent peculiarity, being the only American jurisdiction that is both a city and a state (since Congress passed the District of Columbia Organic Act of 1871). For some reason Yahoo assigned different WOE IDs to the locality (2514815), the county (12587802; though there are no counties in D.C.), and the region (2347567). Oddly, neither one of these is an exact map of D.C.’s border! The locality and county maps are the same, and both include significant chunks of Montgomery County and Prince Georges County (both in Maryland), and smaller parts of Arlington County and Alexandria (both in Virginia). The region code spans even more territory beyond D.C. It looks more appropriate for the metropolitan region. The maps for Maryland (2347579) and Virginia (2347605) are similarly sloppy, spilling over their borders. I haven’t yet discovered the reason for this.

In any case, using the WOE ID is still more accurate than a rectangular bounding box. So, I’ve updated the app to accept them as a parameter. The search for the most interesting photos on December 17, 2011 in D.C. would now look like:

mvjantzen.com/flickr/showpix.php?mindate=2011-12-17 00:00:00&maxdate=2011-12-17 23:59:59&woe=2514815&adjust=-7&fudge=15

Unfortunately, you can’t use the full range of WOE IDs with Flickr. Only WOE IDs representing the 5 types of places will work. So, you can’t plug in the WOE ID for ZIP code 20009 (12765846), area code 202 (24701644), the “America/New_York” (AKA Eastern) time zone (56043648), or “land features” like The Mall (23503223). For these other types of places, you have to find the bounding box and then use those coordinates.

So, the hardest part of using WOE IDs is finding the number you want. Once you have that, including it in a Flickr API search is easy.

Using “Where on Earth” Codes in Flickr

Leave a Reply