query-254b8ffc12658d0a1845c4cfc4e8ce03
Map query on ancient locations in ScotlandForts (filtered by map location)
Use at
- https://query.wikidata.org/sparql
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX p: <http://www.wikidata.org/prop/>
#defaultView:Map
SELECT DISTINCT (?typeLabel AS ?layer) ?label ?loc ?stone ?picURI ?extURI ?tDesc
WHERE
{
{ { ?stone wdt:P31 wd:Q1666255 .}
UNION
{ ?stone wdt:P31 wd:Q1141208 .}
UNION
{ ?stone wdt:P31 wd:Q373661 .
?stone wdt:P131/wdt:P31 ?where . FILTER (?where = wd:Q15060255 ). }
}. #Obtain Pictish stones plus earlier cup and ring marked stones
?stone wdt:P31 ?tLabel. ?tLabel rdfs:label ?tDesc filter (lang(?tDesc) = "en"). #Place name
?stone
wdt:P625 ?loc ; # location to plot on map
p:P625/psv:P625 ?coord; # coordinate-location statement
rdfs:label ?label filter (lang(?label) = "en"). #Place name
OPTIONAL { ?stone wdt:P718 ?_canmoreID } .
OPTIONAL { ?stone wdt:P709 ?_HSID } .
BIND(IF(BOUND(?_canmoreID),(URI (CONCAT ("https://canmore.org.uk/site/", ?_canmoreID) ) ),
IF(BOUND(?_HSID),(URI (CONCAT ("https://portal.historicenvironment.scot/designation/", ?_HSID) ) ), ?_HSID ) ) AS ?extURI).
OPTIONAL { ?stone wdt:P18 ?picURI } .
#BIND(IF(str(?tDesc) = "Pictish stone", "Pictish stone", "Cup and ring stone") AS ?typeLabel). # alt for summary map
BIND(IF(BOUND(?picURI),?tDesc,(CONCAT (?tDesc, " without image") ) ) AS ?typeLabel).
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v9("?_HSID")
v8("?_canmoreID")
v7("?coord")
v10("?extURI"):::projected
v1("?label"):::projected
v13("?layer")
v6("?loc"):::projected
v11("?picURI"):::projected
v3("?stone"):::projected
v2("?tDesc"):::projected
v5("?tLabel")
v12("?typeLabel"):::projected
v4("?where")
a1((" "))
a2((" "))
c4(["wd:Q1141208"]):::iri
c6(["wd:Q373661"]):::iri
c3(["wd:Q1666255"]):::iri
f0[["?label = 'en'"]]
f0 --> v1
f1[["?tDesc = 'en'"]]
f1 --> v2
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
f2[["?where = 'wd:Q15060255'"]]
f2 --> v4
v3 --"p:direct/P31"--> c6
v3 --"p:direct/P131"--> a1
a1 --"p:direct/P31"--> v4
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P31"--> c4
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v3 --"p:direct/P31"--> c3
end
union0r <== or ==> union0l
end
v3 --"p:direct/P31"--> v5
v5 --"rdfs:label"--> v2
v3 --"p:direct/P625"--> v6
v3 --"p:P625"--> a2
a2 --"p:statement/value/P625"--> v7
v3 --"rdfs:label"--> v1
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P718".-> v8
end
subgraph optional1["(optional)"]
style optional1 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P709".-> v9
end
bind3[/"if(bound(?_canmoreID),concat('https://canmore.org.uk/site/',?_canmoreID),if(bound(?_HSID),concat('https://portal.historicenvironment.scot/designation/',?_HSID),?_HSID))"/]
v8 --o bind3
v9 --o bind3
bind3 --as--o v10
subgraph optional2["(optional)"]
style optional2 fill:#bbf,stroke-dasharray: 5 5;
v3 -."p:direct/P18".-> v11
end
bind4[/"if(bound(?picURI),?tDesc,concat(?tDesc,' without image'))"/]
v11 --o bind4
v2 --o bind4
bind4 --as--o v12
bind5[/"?typeLabel"/]
v12 --o bind5
bind5 --as--o v13