query-24535bae3b8ee62c7d729e318692e44d
Map of railway lines
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX psv: <http://www.wikidata.org/prop/statement/value/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
#defaultView:Map{"hide":["?coord1", "?coord1lat", "?coord1lon", "?coord2", "?coord2lat", "?coord2lon", "?str", "?line"]}
SELECT * WHERE {
?comm1 wdt:P31/wdt:P279*/wdt:P361 wd:Q22667 ; wdt:P17 wd:Q213 ; wdt:P625 ?coord1 ; wdt:P197 ?comm2 .
MINUS { ?comm1 p:P31 [ ps:P31 wd:Q55488 ; pq:P582 [] ] } .
MINUS { ?comm2 p:P31 [ ps:P31 wd:Q55488 ; pq:P582 [] ] } .
MINUS { ?comm1 p:P31 [ ps:P31 wd:Q928830 ] } .
MINUS { ?comm2 p:P31 [ ps:P31 wd:Q928830 ] } .
?comm2 wdt:P625 ?coord2 .
?comm1 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord1lon; wikibase:geoLatitude ?coord1lat; ] ] .
?comm2 p:P625 [ ps:P625 []; psv:P625 [ wikibase:geoLongitude ?coord2lon; wikibase:geoLatitude ?coord2lat; ] ] .
BIND(CONCAT('LINESTRING (', STR(?coord1lon), ' ', STR(?coord1lat), ',', STR(?coord2lon), ' ', STR(?coord2lat), ')') AS ?str) .
BIND(STRDT(?str, geo:wktLiteral) AS ?line) .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v1("?comm1"):::projected
v3("?comm2"):::projected
v2("?coord1"):::projected
v6("?coord1lat"):::projected
v5("?coord1lon"):::projected
v4("?coord2"):::projected
v8("?coord2lat"):::projected
v7("?coord2lon"):::projected
v10("?line"):::projected
v9("?str"):::projected
a13((" "))
a4((" "))
a6((" "))
a1((" "))
a2((" "))
a3((" "))
a5((" "))
a7((" "))
a8((" "))
a9((" "))
a11((" "))
a12((" "))
a14((" "))
a10((" "))
c4(["wd:Q22667"]):::iri
c13(["wd:Q928830"]):::iri
c6(["wd:Q213"]):::iri
c10(["wd:Q55488"]):::iri
v1 --"p:direct/P31"--> a1
a1 --"p:direct/P279"--> a2
a2 --"p:direct/P361"--> c4
v1 --"p:direct/P17"--> c6
v1 --"p:direct/P625"--> v2
v1 --"p:direct/P197"--> v3
subgraph minus0["MINUS"]
style minus0 stroke-width:6px,fill:pink,stroke:red;
a3 --"p:statement/P31"--> c10
a3 --"p:qualifier/P582"--> a4
v1 --"p:P31"--> a3
end
subgraph minus1["MINUS"]
style minus1 stroke-width:6px,fill:pink,stroke:red;
a5 --"p:statement/P31"--> c10
a5 --"p:qualifier/P582"--> a6
v3 --"p:P31"--> a5
end
subgraph minus2["MINUS"]
style minus2 stroke-width:6px,fill:pink,stroke:red;
a7 --"p:statement/P31"--> c13
v1 --"p:P31"--> a7
end
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
a8 --"p:statement/P31"--> c13
v3 --"p:P31"--> a8
end
v3 --"p:direct/P625"--> v4
a9 --"p:statement/P625"--> a10
a11 --"wikibase:geoLongitude"--> v5
a11 --"wikibase:geoLatitude"--> v6
a9 --"p:statement/value/P625"--> a11
v1 --"p:P625"--> a9
a12 --"p:statement/P625"--> a13
a14 --"wikibase:geoLongitude"--> v7
a14 --"wikibase:geoLatitude"--> v8
a12 --"p:statement/value/P625"--> a14
v3 --"p:P625"--> a12
bind4[/"concat('LINESTRING (',str(?coord1lon),' ',str(?coord1lat),',',str(?coord2lon),' ',str(?coord2lat),')')"/]
v5 --o bind4
v6 --o bind4
v7 --o bind4
v8 --o bind4
bind4 --as--o v9
bind5[/"STRDT(?str,'geo:wktLiteral')"/]
v9 --o bind5
bind5 --as--o v10