Last active
October 19, 2017 11:50
-
-
Save p1d1d1/3bce362dcaec3330b28a6dbd56839328 to your computer and use it in GitHub Desktop.
Get the coat of arms image form Wikidata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> | |
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> | |
PREFIX wdt: <http://www.wikidata.org/prop/direct/> | |
PREFIX wikibase: <http://wikiba.se/ontology#> | |
PREFIX skos: <http://www.w3.org/2004/02/skos/core#> | |
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | |
PREFIX wd: <http://www.wikidata.org/entity/> | |
PREFIX fn: <http://www.w3.org/2005/xpath-functions#> | |
PREFIX geo: <http://www.opengis.net/ont/geosparql#> | |
SELECT ?Municipality ?Name ?Coords ?CoordsLabel WHERE { | |
?Municipality a <http://www.geonames.org/ontology#A.ADM3> . #municipality | |
?Municipality <http://schema.org/name> ?Name . | |
?Municipality <http://www.geonames.org/ontology#parentADM1> ?InCanton . | |
?InCanton <http://schema.org/name> ?CantonName . | |
?Municipality <http://purl.org/dc/terms/issued> ?Date . | |
?Municipality <https://ld.geo.admin.ch/def/bfsNumber> ?bfsNumber . #connect to the ?bfsNumber found in wikidata. | |
?Municipality geo:hasGeometry ?Geometry . | |
?Geometry geo:asWKT ?Coords . | |
#Filter for Municipalities - Version 2017 | |
FILTER (?Date >= "2017-01-01"^^xsd:date) | |
#FILTER for Municipalities in Canton Bern. Change the name for other Cantons (https://ld.geo.admin.ch/boundaries/canton/). | |
FILTER (?CantonName = "Bern") | |
{ | |
SELECT DISTINCT (xsd:integer(?bfs) AS ?bfsNumber) ?WikidataURI ?CoordsLabel WHERE { | |
SERVICE <https://query.wikidata.org/bigdata/namespace/wdq/sparql> | |
{ | |
?WikidataURI wdt:P771 ?bfs . #look for bfs number in WD | |
?WikidataURI wdt:P31 wd:Q70208 . #municipality of Switzerland | |
#?WikidataURI wdt:P473 ?CoordsLabel . | |
?WikidataURI wdt:P94 ?imgURL . | |
} | |
BIND (CONCAT('<img src="', ?imgURL, '">') AS ?CoordsLabel) . | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment