Skip to content

Instantly share code, notes, and snippets.

@Dulani
Last active August 29, 2015 14:09
Show Gist options
  • Save Dulani/209da7c78812c0f9dd9f to your computer and use it in GitHub Desktop.
Save Dulani/209da7c78812c0f9dd9f to your computer and use it in GitHub Desktop.
SPARQL Query for Army Installation lat/lon
# A quick way to pull a lat/lon table off Wikipedia for "all" US Army bases.
# SPARQL: on http://dbpedia.org/sparql
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT ?name ?label ?lat ?lon ?url
WHERE {
?army <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:United_States_Army_posts> .
?army foaf:name ?name .
?army foaf:isPrimaryTopicOf ?url .
# Comment: would be nice to figure out how to stick a "dbpedia resource" link in here too.
OPTIONAL {?army geo:lat ?lat .}
OPTIONAL {?army geo:long ?lon . }
?army rdfs:label ?label . #Need to filter on english only, otherwise, there is lots of chaff (in other languages)
FILTER( lang(?label)="en" )
}
ORDER by ?name
LIMIT 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment