query-df8c8805eb1505d8a2f3f9bfa0d93d8a
The subway network in Stockholm and all the stations
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX wikibase: <http://wikiba.se/ontology#>
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 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#>
PREFIX bd: <http://www.bigdata.com/rdf#>
#title:The subway network in Stockholm
#defaultView:Map{"hide":["?coords", "?line","?rgb"]}
SELECT ?station ?stationLabel ?coords ?line ?layer ?rgb (SAMPLE(?image) AS ?image) (sample(year(?opening)) as ?opening) WHERE {
?station wdt:P31 wd:Q928830;
wdt:P131* wd:Q104231;
wdt:P625 ?coords;
p:P197 ?pred.
?pred ps:P197 ?conn;
pq:P81 ?subwayLine.
MINUS { ?pred pq:P582 [] }
OPTIONAL { ?station wdt:P18 ?image }.
OPTIONAL { ?station wdt:P1619 ?opening }.
?conn wdt:P625 ?cds;
wdt:P31 wd:Q928830.
BIND(IF(xsd:double(?depth/10) = xsd:integer(?depth/10),?cds,"") as ?coords)
?conn p:P625/psv:P625/wikibase:geoLatitude ?lat1 ; p:P625/psv:P625/wikibase:geoLongitude ?lon1 .
?station p:P625/psv:P625/wikibase:geoLatitude ?lat2 ; p:P625/psv:P625/wikibase:geoLongitude ?lon2 .
BIND(CONCAT('LINESTRING(', STR(?lon1), ' ', STR(?lat1), ',', STR(?lon2), ' ', STR(?lat2), ')') AS ?str) . BIND(STRDT(?str, geo:wktLiteral) AS ?line)
?subwayLine wdt:P465 ?rgb .
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv". ?subwayLine rdfs:label ?layer. ?station rdfs:label ?stationLabel }
}
GROUP BY ?station ?stationLabel ?coords ?line ?layer ?rgb