Wikidata:WP EBath/Query examples
Jump to navigation
Jump to search
Eionet bathidentifier in Wikidata
Try it!
Try it!
Try it!
Swedish Bathing waters in a Nature reserve
Swedish Bathing waters with line to connected water
Badplatser nära dig enligt Wikidata med recensioner hos badkartan
Sources
[edit]Wikidata SPARQL
[edit]Example queries:
Maps
[edit]Map of of baths with Eionet bathing Water ID (P9616)
[edit]#title: Eionet bathidentifier in Wikidata
#defaultView:Map{"hide":["?coord","?layer"], "layer": "?countryLabel"}
SELECT ?node (REPLACE(STR(?node), ".*Q", "Q") AS ?qid) ?nodeLabel ?nodeDescription ?BathId ?countryLabel ?www
(SAMPLE(?coord) AS ?coord)
(SAMPLE(?img) AS ?img) WHERE {
?node wdt:P9616 ?BathId.
OPTIONAL {?node wdt:P18 ?img}
OPTIONAL {?node wdt:P17 ?country}
OPTIONAL {?node wdt:P856 ?www}
?node wdt:P625 ?coord
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
} Group By ?node ?nodeLabel ?nodeDescription ?BathId ?countryLabel ?www
order by ?countryLabel
Map of of bathing waters with/without an image in Wikidata
[edit]- with link WikishootMe
#defaultView:Map{"hide":["?coord"], "layer": "?layer"}
SELECT ?node ?nodeLabel ?nodeDescription ?WikiShootMe ?bathIdentifier ?layer ?article ?countryLabel (SAMPLE(?coord) AS ?coord) (SAMPLE(?img) AS ?img) (SAMPLE(?web) AS ?web) WHERE {
{
{ ?node wdt:P6104 wd:Q106774536. }
UNION
{ ?node wdt:P6104 wd:Q107096245. }
}
OPTIONAL { ?node wdt:P18 ?img. }
OPTIONAL { ?node wdt:P17 ?country. }
OPTIONAL { ?node wdt:P856 ?web. }
OPTIONAL { ?node wdt:P9161 ?bathIdentifier }
?node wdt:P625 ?coord.
OPTIONAL {
?article schema:about ?node;
schema:inLanguage "en".
}
BIND(IF(BOUND(?img), "Picture", "Missing picture") AS ?layer)
BIND(URI(CONCAT("https://wikishootme.toolforge.org/#q=", REPLACE(STR(?node), "http://www.wikidata.org/entity/", ""))) AS ?WikiShootMe)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}
GROUP BY ?node ?nodeLabel ?nodeDescription ?bathIdentifier ?article ?countryLabel ?layer ?WikiShootMe
Picture gallery of images depicting a bathing water in this project Project European Bath Waters (Q107096245)
[edit]#defaultView:ImageGrid{"hide":["?image "]}
SELECT DISTINCT ?itemLabel ?image ?EIONETbathingIdentifier ?www
WITH
{ SELECT ?item ?itemLabel ?itemDescription ?EIONETbathingIdentifier ?www WHERE
{ SERVICE <https://query.wikidata.org/sparql>
{?item wdt:P6104 wd:Q107096245.
OPTIONAL {?item wdt:P9616 ?EIONETbathingIdentifier}
OPTIONAL {?item wdt:P856 ?www}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". ?item rdfs:label ?itemLabel .}
}
}
} AS %Wikidataitems
WHERE
{ INCLUDE %Wikidataitems .
?file wdt:P180 ?item.
?file schema:contentUrl ?url.
bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)
}
Sweden
[edit]Old Swedish bath pictures from a museum
[edit]#defaultView:ImageGrid{"hide":["?image "]}
#SELECT DISTINCT ?file ?item ?itemLabel ?image ?Digitaltmuseum
SELECT DISTINCT ?itemLabel ?image ?Digitaltmuseum
WITH
{ SELECT ?item ?itemLabel ?itemDescription WHERE
{ SERVICE <https://query.wikidata.org/sparql>
{?item wdt:P6104 wd:Q106774536.
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". ?item rdfs:label ?itemLabel .}
}
}
} AS %Wikidataitems
WHERE
{ INCLUDE %Wikidataitems .
?file wdt:P180 ?item.
?file wdt:P7847 ?DigID.
BIND(URI(CONCAT("https://digitaltmuseum.org/",?DigID)) AS ?Digitaltmuseum)
?file schema:contentUrl ?url.
bind(iri(concat("http://commons.wikimedia.org/wiki/Special:FilePath/", wikibase:decodeUri(substr(str(?url),53)))) AS ?image)
}
Bathing waters in protected areas in Sweden
[edit]- we have Swedish Nature reserves with geojson
#title: Swedish Bathing waters in a Nature reserve
#defaultView:Map{"hide":["?coord","?layer"], "layer": "?platsLabel"}
SELECT ?node (REPLACE(STR(?node), ".*Q", "Q") AS ?qid) ?nodeLabel ?nodeDescription ?BathId ?Hav ?adminLabel ?HavsAPI
(SAMPLE(?coord) AS ?coord) ?plats ?platsLabel ?NatReg ?Nat ?shape WHERE {
?node wdt:P6104 wd:Q106774536.
OPTIONAL {?node wdt:P9616 ?BathId}
{?node wdt:P3018 ?plats.
?plats wdt:P3613 ?NatReg}
?node wdt:P625 ?coord.
?plats wdt:P3896 ?shape
BIND (URI(CONCAT("https://badplatsen.havochvatten.se/badplatsen/api/detail/",?BathId)) AS ?HavsAPI)
BIND(URI(CONCAT("https://badplatsen.havochvatten.se/badplatsen/karta/#/bath/",?BathId)) AS ?Hav)
BIND(URI(CONCAT("http://skyddadnatur.naturvardsverket.se/sknat/?nvrid=",?NatReg)) AS ?Nat)
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv". }
} Group By
?node ?nodeLabel ?nodeDescription ?BathId ?adminLabel ?HavsAPI ?Hav ?NatReg ?plats ?platsLabel ?Nat ?shape
order by ?platsLabel
Bathing waters in Sweden connected to water showing distance
[edit]- located in or next to body of water (P206)
- Lake ID (Sweden) (P761) is unique id of Swedish water
- A line is shown from the coordinate of the bathing water to the coordinate of the connected water
#title: Swedish Bathing waters with line to connected water
#defaultView:Map{"hide":["?bathcoord","?lakecoord","?line","?str","?layer"]}
SELECT ?str ?bathingwater ?bathingwaterLabel ?bathcoord ?lake ?lakeLabel ?lakecoord ?dist ?line ?SJOID ?layer ?EionetBathingWaterIDentifier ?Hav ?VISS WHERE {
?bathingwater wdt:P6104 wd:Q106774536.
?bathingwater wdt:P625 ?xx.
?bathingwater p:P625 [ a wikibase:BestRank ;
psv:P625 [
wikibase:geoLatitude ?bathcoordlat ;
wikibase:geoLongitude ?bathcoordlon ;
wikibase:geoGlobe ?globe ;
] ;
ps:P625 ?bathcoord
]
OPTIONAL { ?bathingwater wdt:P9616 ?EionetBathingWaterIDentifier. }
{
?bathingwater wdt:P206 ?lake.
?lake wdt:P625 ?rr.
?lake p:P625 [a wikibase:BestRank ;
psv:P625 [
wikibase:geoLatitude ?lat ;
wikibase:geoLongitude ?long ;
wikibase:geoGlobe ?globe2 ;
] ;
ps:P625 ?lakecoord
]
OPTIONAL { ?lake wdt:P761 ?SJOID. }
}
BIND(geof:distance(?bathcoord, ?lakecoord) as ?dist) .
#filter (?dist >= 3)
BIND (floor(?dist/10)*10 as ?layer)
BIND(CONCAT('LINESTRING (', STR(?bathcoordlon), ' ', STR(?bathcoordlat), ',', STR(?long), ' ', STR(?lat), ')') AS ?str) .
BIND(STRDT(?str, geo:wktLiteral) AS ?line)
BIND(URI(CONCAT("https://badplatsen.havochvatten.se/badplatsen/karta/#/bath/",?EionetBathingWaterIDentifier)) AS ?Hav)
BIND(URI(CONCAT("https://viss.lansstyrelsen.se/Waters.aspx?waterEUID=SE",?SJOID)) AS ?VISS)
SERVICE wikibase:label { bd:serviceParam wikibase:language "en,sv". }
}
ORDER BY DESC(?dist)
Bathing water near me that is connected to Badkartan
[edit]- badkartan.se has reviews of the bath places = Badkartan.se ID (P9615)
#defaultView:Map
#title: Badplatser nära dig enligt Wikidata med recensioner hos badkartan
SELECT ?bath ?bathLabel ?location ?avst ?img ?badkartan WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en,de". }
SERVICE wikibase:around {
?bath wdt:P625 ?location.
bd:serviceParam wikibase:center "[AUTO_COORDINATES]".
bd:serviceParam wikibase:radius "30".
bd:serviceParam wikibase:distance ?dist.
}
?bath wdt:P6104/wdt:P361* wd:Q107096245.
OPTIONAL{?bath wdt:P18 ?img}
{?bath wdt:P9615 ?badkartanid}
OPTIONAL {?bath wdt:P856 ?URL}
BIND(URI(CONCAT("https://www.badkartan.se/",?badkartanid)) AS ?badkartan)
BIND (CONCAT("Distance (km) ",str(?dist)) AS ?avst)}
Open Street
[edit]OSM SPARQL
[edit]Most prolific mappers of swimming_area
[edit]#Most prolific mappers of swimming_area SELECT ?user (COUNT(*) AS ?count) WHERE { # Query OpenStreetMap for Swimmingarea and the users who last edited them ?Swimmingarea osmt:leisure "swimming_area"; osmm:user ?user. # Exclude user names that end with the word "bot" FILTER(!REGEX(?user, "\\bbot$")) } GROUP BY ?user ORDER BY DESC(?count) LIMIT 10
Leisure swimming_area without a Wikidata tag
[edit]Open Street Map / OverPass
[edit]Count swimming_area in Sweden
[edit][out:csv(::count, ::"count:nodes", ::"count:ways", ::"count:relations")] [timeout:125]; ( area["name"="Sverige"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="swimming_area"]; ); ); out count;
@count | @count:nodes | @count:ways | @count:relations |
---|---|---|---|
968 | 888 | 61 | 14 |
Count swimming_area in Sweden without Wikidata
[edit][out:csv(::count, ::"count:nodes", ::"count:ways", ::"count:relations")] [timeout:125]; ( area["name"="Sverige"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="swimming_area"][!"wikidata"]; ); ); out count;
@count | @count:nodes | @count:ways | @count:relations |
---|---|---|---|
250 | 198 | 39 | 8 |