Skip to content

Instantly share code, notes, and snippets.

@pwin
Created March 3, 2014 19:54
Show Gist options
  • Save pwin/9333250 to your computer and use it in GitHub Desktop.
Save pwin/9333250 to your computer and use it in GitHub Desktop.
### Query to find all postcodes that reference Glasgow City as their District
### and return postcode uri, label and geocoding
### 2014-03-03
### Peter Winstanley
PREFIX admingeo: <http://data.ordnancesurvey.co.uk/ontology/admingeo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX gaz: <http://data.ordnancesurvey.co.uk/ontology/50kGazetteer/>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX geometry: <http://data.ordnancesurvey.co.uk/ontology/geometry/>
PREFIX georss: <http://www.georss.org/georss/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX spatial: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
PREFIX postcode: <http://data.ordnancesurvey.co.uk/ontology/postcode/>
PREFIX place: <http://data.ordnancesurvey.co.uk/ontology/place/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
select ?pc ?postcode ?lat ?long ?easting ?northing
{?pc postcode:district <http://data.ordnancesurvey.co.uk/id/7000000000030631>;
rdfs:label ?postcode .
optional {?pc geo:lat ?lat.}
optional {?pc geo:long ?long.}
optional {?pc spatial:easting ?easting.}
optional {?pc spatial:northing ?northing.}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment