Eat your greens!

Actually, I am a rocket scientist
Home » astronomy » Mapping the sky with YQL and

Mapping the sky with YQL and

Posted in astronomy, geekage, yql

Machine tags and Google Sky, originally uploaded by eat your greens.

Astronomy photographer of the year has been open for a couple of months now, and the astrophoto Flickr group has a few hundred photos now. The amazing bot has been scanning the group and about 70 photos have been tagged with their celestial coordinates, using astro: machine tags.

Flickr is one of the data sources available for use in YQL. Here’s a YQL query to grab the astro: tags for a photo if you know its Flickr id.

select tags.tag.raw from
where photo_id='3330304396' and tags.tag.raw like 'astro:%'

The Google Earth plugin allows you to display an interactive map of the night sky on a  web page and supports the Google Earth API too. Have a look at for some great examples, including a planetarium. Since the YQL query above returns tags containing the celestial coordinates of a flickr photo, those coordinates can be passed to the Google Earth plugin to display the same area of the night sky. Here’s an example for the Horsehead Nebula in Orion. View the source code to see how the astronomical coordinates are parsed from the YQL data and sent to the plugin.

That’s good if we know the id of a single photo. What if we want to display all the photos from the astrophoto group that are tagged with astro:RA (the celestial equivalent of geo:long)? The YQL query to grab the photo details and astro: tags for multiple photos is more involved, using a join to get the photo ids, but still quite straightforward.

select farm, server, id, secret, title, urls.url.content, tags.tag.raw from
		where (tags.tag.raw like 'astro:%')
		and photo_id in (
			select id from
			where group_id='973956@N23'
			and machine_tags='astro:RA='

Here’s an image gallery generated using that YQL query. Click on the photo thumbnails to change the sky view. Again, you can view the source code to see the javascript that generates the gallery. The code needs improvement but hopefully demonstrates how the YQL query results are parsed and stored in an array of photos, keyed on the photo ids.

Finally, if we know exactly which photos we want to use in our gallery, we can replace the inner select with a list of id numbers.

select farm, server, id, secret, title, urls.url.content, tags.tag.raw from
		where (tags.tag.raw like 'astro:%')
		and photo_id in (
			2955988513, 2970415185, 2796500688

Here’s a looping slideshow, based on that query, which moves through a series of photos of our Milky Way galaxy, from to in .

If you want to find out more about the machine tags that we’re using in the astrophoto group, I wrote a brief introduction for developers on the Royal Observatory web site.