Archive

Posts Tagged ‘OS OpenSpace’

Experiments with schema.org

August 26, 2013 7 comments

Directly quoting from schema.org:

This site provides a collection of schemas, i.e., html tags, that webmasters can use to markup their pages in ways recognized by major search providers. Search engines including Bing, Google, Yahoo! and Yandex rely on this markup to improve the display of search results, making it easier for people to find the right web pages.

Many sites are generated from structured data, which is often stored in databases. When this data is formatted into HTML, it becomes very difficult to recover the original structured data. Many applications, especially search engines, can benefit greatly from direct access to this structured data. On-page markup enables search engines to understand the information on web pages and provide richer search results in order to make it easier for users to find relevant information on the web. Markup can also enable new tools and applications that make use of the structure.

My favourite band, New Model Army, are touring later this year so I thought creating a website for their UK tour dates would be a good way to experiment with schema.org markup. First off we have a webpage for the UK leg of their winter tour:

http://www.johngoodwin.me.uk/event/newmodelarmy-uk-wintertour-2013

which is a kind of Music Event, and this is related to a number of sub events such as:

http://www.johngoodwin.me.uk/event/newmodelarmy-uk-Aberdeen-20131112

which is also a kind of Music Event. Each of these events are related to a venue, via the ‘location‘ predicate:

http://www.johngoodwin.me.uk/venue/The-Garage-Aberdeen

I have related each of the venues to locations in the Ordnance Survey Linked Data using the contained in predicate.

For each of the events I have included further markup such as the start date, end date, ticket sites (via the offers predicate) and also links to other pages about the event via sameAs. Similarly I have linked pages about each venue to other pages about that venue via sameAs.

All of the markup is done using RDFa. You can view the machine readable content using the Google Structured Data Testing tool or this RDFa Parser. Here are some examples:

New Model Army UK Winter Tour 2013: rich snippets, RDFa distiller

Aberdeen tour date: rich snippets, RDFa distiller

The Garage Aberdeen (venue): rich snippets, RDFa distiller

Mapping is provided by OS OpenSpace.

Extra: someone asked me what the experiment was. Maybe not much of an experiment really, but simply put I’m curious to find out what happens should these pages get picked up by Google et al., and curious to see what they do with them.

Putting SPARQL on the Map with Ordnance Survey Linked Data & OS OpenSpace

August 20, 2013 Leave a comment

A colleague was asking me if I knew how to plot SPARQL query results from the Ordnance Survey linked data onto an OS OpenSpace map. Although I’d done it a few times before, it was never something I’d blogged. So here goes…

This is a lot easier than you might imagine. The first thing you want to do is perform your SPARQL query and get back the results as a csv file. I blogged about this a while back, but here is a quick recap. Let us suppose I want to plot a centroid for all the districts in England, and have their name appear in the pop up text. It is easy to perform a query to get back the easting, northing and name for all the districts. First go to the Boundary-Line(TM) SPARQL endpoint and enter the following query:

select ?x ?y ?name
where
{
?a <http://www.w3.org/2000/01/rdf-schema#label> ?name .
?a <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/easting> ?x .
?a <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/northing> ?y .
?a a <http://data.ordnancesurvey.co.uk/ontology/admingeo/District> .
}

Make sure the response format is set to CSV. Now click the query button. The “Reponse” box will have your query results, and the “Request box” should have a long complicated looking URL:

http://data.ordnancesurvey.co.uk/datasets/boundary-line/apis/sparql?query=select+%3Fx+%3Fy+%3Fname%0D%0Awhere%0D%0A%7B%0D%0A%3Fa+%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23label%3E+%3Fname+.%0D%0A%3Fa+%3Chttp%3A%2F%2Fdata.ordnancesurvey.co.uk%2Fontology%2Fspatialrelations%2Feasting%3E+%3Fx+.%0D%0A%3Fa+%3Chttp%3A%2F%2Fdata.ordnancesurvey.co.uk%2Fontology%2Fspatialrelations%2Fnorthing%3E+%3Fy+.%0D%0A%3Fa+a+%3Chttp%3A%2F%2Fdata.ordnancesurvey.co.uk%2Fontology%2Fadmingeo%2FDistrict%3E+.%0D%0A%7D&output=csv

So far so easy.

Now we come to the OS OpenSpace part. It is easy to plot a text file in OS OpenSpace. To find out how go to the OS OpenSpace Code Playground and select the link “Add markers and text from a file“. You should see an example mashup showing some points plotted. To see what is going on click on “Edit in Code Playground” and you should see the javascript & HTML that produces the map. In the Javascript window you can edit the code and preview the changes. For this example the first simple thing you need to do is adjust the zoom level. To do this change:

    osMap.setCenter(new OpenSpace.MapPoint(400000, 400000), 7);

to

    osMap.setCenter(new OpenSpace.MapPoint(400000, 400000), 1);

so we are zoomed all the way out.

We now need to change the input text file. To do this change the following line in the sample code:

    var markersFile = “/res/mymarkers.txt”;

In this line replace /res/mymarkers.txt with the URL you got from the SPARQL endpoint in the Request box. Once you have done that click the ‘render’ button and you should now see your results plotted on an OS OpenSpace map. Click on a map pointer to display the name of the district. Easy as that.

As an exercise to the reader…consult my last few blog posts and display markers for postcodes in a district of your choosing.

SPARQL your way to a Stupor

February 15, 2009 4 comments

A few years back two intrepid explorers set out to survery all of the pubs in Southampton. Their adventure is documented here

A while back I decided to turn their page into linked data and you can see the result here. Mapping is provided by OS OpenSpace as the cartography is far nicer than that of Google or Yahoo! (IMHO of course :)). As of today the site is linked up to Revyu (in both the RDF and HTML) where applicable. You can also now browse the RDF using the OpenLink Data Explorer, Zitgist or Tabulator. No SPARQL endpoint as yet, but maybe one day.

Reblog this post [with Zemanta]
Follow

Get every new post delivered to your Inbox.

Join 2,189 other followers