Skip to content

Instantly share code, notes, and snippets.

@byteofprash
Created February 27, 2018 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byteofprash/0a3435e59c7c5e4e60615e74747c3322 to your computer and use it in GitHub Desktop.
Save byteofprash/0a3435e59c7c5e4e60615e74747c3322 to your computer and use it in GitHub Desktop.
A spraql query to get the lat long of certain cities
## Sparql Query to get the lat long of certain cities
SELECT DISTINCT ?countryLabel ?label ?lat ?long WHERE {
{?city rdf:type dbo:City} UNION {?city rdf:type dbo:PopulatedPlace}
?city rdfs:label ?label ;
geo:lat ?lat ;
geo:long ?long ;
dbo:country ?country ;
rdfs:label ?name .
?country rdfs:label ?countryLabel .
FILTER (lang(?label) = 'en' and lang(?countryLabel) = 'en')
FILTER (regex(?countryLabel,"Germany") or regex(?countryLabel,"Austria") or regex(?countryLabel,"France") or regex(?countryLabel,"Italy"))
FILTER (regex(?label, "Berlin") or regex(?label, "Munich") or
regex(?label, "Dusseldorf") or
regex(?label, "Frankfurt") or
regex(?label, "Cologne") or
regex(?label, "Hamburg") or
regex(?label, "Stuttgart"))
}
## Sparql Query to get the lat long of certain cities
SELECT DISTINCT ?countryLabel ?label ?lat ?long WHERE {
{?city rdf:type dbo:City} UNION {?city rdf:type dbo:PopulatedPlace}
?city rdfs:label ?label ;
geo:lat ?lat ;
geo:long ?long ;
dbo:country ?country ;
rdfs:label ?name .
?country rdfs:label ?countryLabel .
FILTER (lang(?label) = 'en' and lang(?countryLabel) = 'en')
FILTER (regex(?countryLabel,"Germany") or regex(?countryLabel,"Austria") or regex(?countryLabel,"France") or regex(?countryLabel,"Italy"))
FILTER (regex(?label, "Berlin") or regex(?label, "Munich") or
regex(?label, "Dusseldorf") or
regex(?label, "Frankfurt") or
regex(?label, "Cologne") or
regex(?label, "Hamburg") or
regex(?label, "Stuttgart"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment