Wikidata:WP OGyms/Query examples
SPARQL Wikidata
editOutdoor Gyms in Wikidata
edit#title: Outdoor Gyms in Wikidata
#defaultView:Map{"hide":["?coord","?layer"], "layer": "?countryLabel"}
SELECT ?id ?item ?itemLabel ?itemDescription ?img ?coord ?www ?countryLabel WHERE {
{{?item wdt:P31/wdt:P279* wd:Q692630}
UNION
{ ?item wdt:P912 wd:Q692630.
}}
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,sv,de" .
}
OPTIONAL { ?item wdt:P18 ?img }
OPTIONAL { ?item wdt:P17 ?country }
OPTIONAL { ?item wdt:P856 ?www }
OPTIONAL { ?item wdt:P625 ?coord }
}
Outdoor gyms 10 km from your current location
edit- Works if you allow your browser get your current location otherwise you get Berlin as the center of the universe
#defaultView:Map
#title: Outdoor gyms 10 km from your current location
SELECT ?outdoorgym ?outdoorgymLabel ?location ?avst ?img WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
SERVICE wikibase:around {
?outdoorgym wdt:P625 ?location.
bd:serviceParam wikibase:center "[AUTO_COORDINATES]".
bd:serviceParam wikibase:radius "10".
bd:serviceParam wikibase:distance ?dist.
}
?outdoorgym wdt:P31 wd:Q692630.
OPTIONAL{?outdoorgym wdt:P18 ?img}
OPTIONAL {?outdoorgym wdt:P856 ?URL}
BIND (CONCAT("Distance (km) ",str(?dist)) AS ?avst)
}
Map of of Outdoor gyms with/without an image in Wikidata
edit- with link WikishootMe
#title: Outdoor Gyms with pictures in Wikidata
#defaultView:Map{"hide":["?coord"], "layer": "?layer"}
SELECT ?node ?nodeLabel ?nodeDescription ?WikiShootMe ?layer ?countryLabel
(SAMPLE(?coord) AS ?coord)
(SAMPLE(?img) AS ?img)
(SAMPLE(?web) AS ?web) WHERE {
?node wdt:P6104 wd:Q107186275
OPTIONAL { ?node wdt:P18 ?img. }
OPTIONAL { ?node wdt:P17 ?country. }
OPTIONAL { ?node wdt:P856 ?web. }
?node wdt:P625 ?coord.
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 ?countryLabel ?layer ?WikiShootMe
Outdoor gyms at bathwaters
edit#title: Swedish Outdoor gyms next to a bath water
#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:Q107186275.
?item wdt:P6104 wd:Q107186275.
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
Outdoor gyms with no coordinates on a Map
editQuery finding the Administrative location of a outdoor gym with no coordinate
- Nota Bene the layer option will just show one item per coordinate
#title: map where we have outdoor gyms missing coordinates
#defaultView:Map{"hide":["?coord","?layer"], "layer": "?adminLabel"}
SELECT ?item ?itemLabel ?itemDescription ?adminLabel ?www ?coordAdmin ?email WHERE {
?item wdt:P6104 wd:Q107186275.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "sv,en,de" .
}
OPTIONAL { ?item wdt:P131 ?country. }
OPTIONAL { ?item wdt:P131 ?admin.
?admin wdt:P625 ?coordAdmin.
OPTIONAL {?admin wdt:P968 ?email}
}
OPTIONAL { ?item wdt:P856 ?www. }
minus { ?item wdt:P625 ?coord. }
OPTIONAL { ?item wdt:P217 ?id. }
} order by ?adminLabel
Wikidata properties on WD objects in the outdoor gym project
edit#title: Wikidata properties on WD objects in the outdoor gym project
SELECT ?property ?propertyLabel ?propertyDescription ?count WHERE {
{
select ?propertyclaim (COUNT(*) AS ?count) where {
?item wdt:P6104 wd:Q107186275.
?item ?propertyclaim [] .
} group by ?propertyclaim
}
# ?property wikibase:propertyType wikibase:ExternalId .
?property wikibase:claim ?propertyclaim .
SERVICE wikibase:label { # ... include the labels
bd:serviceParam wikibase:language "en,sv" .
}
} ORDER BY DESC (?count)
Sweden
editSwedish outdoor gyms on a map
edit#title:Swedish outdoor gyms on a map
#defaultView:Map{"hide":["?coord"], "layer": "?adminLabel"}
SELECT ?id ?item ?itemLabel ?itemDescription ?img ?coord ?www ?adminLabel WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34. #Q34 Sweden
SERVICE wikibase:label {
bd:serviceParam wikibase:language "sv,en,de" .
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL { ?item wdt:P131 ?admin. }
OPTIONAL { ?item wdt:P856 ?www. }
OPTIONAL { ?item wdt:P625 ?coord. }
OPTIONAL { ?item wdt:P217 ?id. }
} order by ?adminLabel
100 latest built outdoor gyms in Sweden
edit- outdoor gyms need to have inception (P571) set to be on this list
#title:100 latest built outdoor gyms in Sweden
SELECT ?date ?item ?itemLabel ?www ?adminLabel WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34; #Q34 Sweden
wdt:P571 ?plannedDate.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "sv,en,de" .
}
?item wdt:P571 ?date. # date
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL { ?item wdt:P131 ?admin. }
OPTIONAL { ?item wdt:P856 ?www. }
OPTIONAL { ?item wdt:P625 ?coord. }
OPTIONAL { ?item wdt:P217 ?id. }
FILTER (?plannedDate < NOW())
} order by desc(?date)
limit 100
Swedish municipals with no outdoorgyms in Wikidata on a map
edit#title:Swedish municipals with no connected outdoor gyms on a map
#defaultView:Map{"hide":["?coord"], "layer": "?lanidLabel"}
SELECT ?adminItem ?adminItemLabel ?coord ?www ?lanidLabel WHERE {
?adminItem wdt:P31 wd:Q127448;
wdt:P17 wd:Q34.
OPTIONAL { ?adminItem wdt:P625 ?coord. }
MINUS { ?adminItem wd:P576 ?end. }
MINUS { ?adminItem wd:P1366 ?sub. }
OPTIONAL { ?adminItem wdt:P856 ?www. }
?adminItem wdt:P131 ?lanid.
?lanid wdt:P31 wd:Q200547.
MINUS {
?item wdt:P6104 wd:Q107186275;
wdt:P131 ?adminItem.
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
}
Barchart top Swedish municipals regarding nr outdoor gyms
edit#title:Top Swedish municipals regarding nr outdoor gyms
#defaultView:BarChart
SELECT ?adminItem ?adminItemLabel (count(?item) as ?nr) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P131 ?adminItem;
wdt:P17 wd:Q34.
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} group by ?adminItem ?adminItemLabel
order by desc(?nr) limit 50
Top 30 Swedish municipals regarding nr outdoor gyms per capita
edit#title:Top 30 Swedish municipals regarding nr outdoor gyms per capita
#defaultView:BarChart
SELECT ?adminItem ?adminItemLabel (count(?item) as ?nr) ?pop (10000*?nr/?pop AS ?per10000capita) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P131 ?adminItem.
OPTIONAL {?adminItem wdt:P1082 ?pop}
?adminItem wdt:P17 wd:Q34
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} group by ?adminItem ?adminItemLabel ?pop
order by desc(?per10000capita) limit 30
Map with layer of nr outdoor gyms per population in the municipal
edit#defaultView:Map{"hide":["?coord"], "layer": "?per10000capita"}
#title: Map with layer of nr outdoor gyms per population in the municipal
SELECT ?adminItem ?adminItemLabel (count(?item) as ?nr) ?pop (FLOOR(10000*?nr/?pop) AS ?per10000capita) ?coord WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P131 ?adminItem.
OPTIONAL {?adminItem wdt:P1082 ?pop}
?adminItem wdt:P17 wd:Q34.
?adminItem wdt:P625 ?coord
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} group by ?adminItem ?adminItemLabel ?pop ?coord
order by desc(?per10000capita)
Swedish municipals regarding nr outdoor gyms per number employed
edit#title:Swedish municipals regarding nr outdoor gyms per number employed
SELECT ?adminItem ?adminItemLabel (count(?item) as ?nr) ?employed (10000*?nr/?employed AS ?per1000employeed) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P131 ?adminItem.
OPTIONAL {?adminItem wdt:P1128 ?employed}
?adminItem wdt:P17 wd:Q34
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} group by ?adminItem ?adminItemLabel ?pop ?employed
order by desc(?per1000employeed)
Bar charts Top 25 Swedish municipals regarding nr outdoor gyms per number employed
edit#title:Top 25 Swedish municipals regarding nr outdoor gyms per number employed
#defaultView:BarChart
SELECT ?adminItem ?adminItemLabel (count(?item) as ?nr) ?employed (10000*?nr/?employed AS ?per10000capita) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P131 ?adminItem.
OPTIONAL {?adminItem wdt:P1128 ?employed}
?adminItem wdt:P17 wd:Q34
SERVICE wikibase:label { bd:serviceParam wikibase:language "sv,en". }
} group by ?adminItem ?adminItemLabel ?pop ?employed
order by desc(?per10000capita) limit 25
Swedish outdoor gyms with youtube video on a map
edit#defaultView:Map{"hide":["?coord"]}
#title:Outdoor gyms with a youtube video
SELECT ?item ?itemLabel ?itemDescription ?img ?coord ?www ?youtube ?adminLabel WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "sv,en,de" .
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL { ?item wdt:P131 ?admin. }
OPTIONAL { ?item wdt:P856 ?www. }
?item wdt:P1651 ?youtubev.
BIND(URI(CONCAT("https://www.youtube.com/watch?v=",?youtubev)) AS ?youtube)
OPTIONAL { ?item wdt:P625 ?coord. }
}
using metadata from Youtube - map
edit- User:BorkedBot moves metadata from Youtube to Wikidata weekly
- Feature request to also get the youtube name and maybe match it to Wikidata see borked-bot/issues/4
#defaultView:Map{"hide":["?coord"], "layer": "?languageLabel"}
#title:Outdoor Swedish gyms with a youtube video and metadata from Youtube
SELECT ?item ?itemLabel ?img ?coord ?www ?youtube ?adminLabel ?title ?languageLabel ?nrviews ?length WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "sv,en,de" .
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL { ?item wdt:P131 ?admin. }
OPTIONAL { ?item wdt:P856 ?www. }
?item wdt:P1651 ?youtubev.
?item p:P1651 ?Pyoutubev.
OPTIONAL {?Pyoutubev pq:P1810 ?title}
OPTIONAL {?Pyoutubev pq:P407 ?language}
OPTIONAL {?Pyoutubev pq:P5436 ?nrviews}
OPTIONAL {?Pyoutubev pq:P2047 ?length}
BIND(URI(CONCAT("https://www.youtube.com/watch?v=",?youtubev)) AS ?youtube)
OPTIONAL { ?item wdt:P625 ?coord. }
}
using metadata from Youtube - most viewed Swedish outdoor gyms video
edit- I asked for some support see Wikidata:Request_a_query#Swedish_Outdoor_gyms_with_most_viewed_videos_on_youtube
#title:Outdoor gyms in Sweden with most viewed youtube videos
SELECT ?nrviews (SAMPLE(?title) AS ?title) ?youtube (SAMPLE(?item) AS ?WD) (SAMPLE(?OutdoorGym) AS ?OutdoorGym) (SAMPLE(?admin) AS ?admin) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
OPTIONAL {
?item rdfs:label ?OutdoorGym.
FILTER((LANG(?OutdoorGym)) = "sv")
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL {
?item wdt:P131 ?adminId.
?adminId rdfs:label ?admin.
FILTER((LANG(?admin)) = "sv")
}
OPTIONAL { ?item wdt:P856 ?www. }
{
{?item p:P1651 ?Pyoutubev.
?Pyoutubev ps:P1651 ?youtubev.
OPTIONAL { ?Pyoutubev pq:P1810 ?title. }
OPTIONAL { ?Pyoutubev pq:P407 ?language. }
OPTIONAL { ?Pyoutubev pq:P5436 ?nrviews. }
OPTIONAL { ?Pyoutubev pq:P2047 ?length. }
}
}
BIND(URI(CONCAT("https://www.youtube.com/watch?v=", ?youtubev)) AS ?youtube)
OPTIONAL { ?item wdt:P625 ?coord. }
}
GROUP BY ?youtube ?nrviews
ORDER BY DESC (?nrviews)
as a BubbleChart
edit#defaultView:BubbleChart
#title:Outdoor gyms in Sweden with most viewed youtube videos as Bubble Chart
SELECT ?nrviews (SAMPLE(?title) AS ?title) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
OPTIONAL {
?item rdfs:label ?OutdoorGym.
FILTER((LANG(?OutdoorGym)) = "sv")
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL {
?item wdt:P131 ?adminId.
?adminId rdfs:label ?admin.
FILTER((LANG(?admin)) = "sv")
}
OPTIONAL { ?item wdt:P856 ?www. }
{
{?item p:P1651 ?Pyoutubev.
?Pyoutubev ps:P1651 ?youtubev.
OPTIONAL { ?Pyoutubev pq:P1810 ?title. }
OPTIONAL { ?Pyoutubev pq:P407 ?language. }
OPTIONAL { ?Pyoutubev pq:P5436 ?nrviews. }
OPTIONAL { ?Pyoutubev pq:P2047 ?length. }
}
}
BIND(URI(CONCAT("https://www.youtube.com/watch?v=", ?youtubev)) AS ?youtube)
OPTIONAL { ?item wdt:P625 ?coord. }
}
GROUP BY ?youtube ?nrviews
ORDER BY DESC (?nrviews)
NrViews Grouped by producer
edit- The borked bot will in the future also add YouTube channel ID (P2397) --> we can see who has produced the video if the producer is in Wikidata
#title:Nr views of Outdoor gyms videos in Sweden per producer
SELECT ?producerWD ?producer ?description
(sum(?nrviews) AS ?nrViewsTotal)
(count(?nrviews) AS ?nrVideos) ?www WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
{
?item p:P1651 ?Pyoutubev.
?Pyoutubev ps:P1651 ?youtubev.
OPTIONAL { ?Pyoutubev pq:P407 ?language. }
OPTIONAL { ?Pyoutubev pq:P5436 ?nrviews. }
?Pyoutubev pq:P2397 ?channel.
?producerWD wdt:P2397 ?channel.
OPTIONAL {
?producerWD rdfs:label ?producer.
FILTER((LANG(?producer)) = "en")}
OPTIONAL{ ?producerWD schema:description ?description.
FILTER((LANG(?description)) = "en")
}
OPTIONAL { ?producerWD wdt:P856 ?www.}
OPTIONAL { ?producerWD wdt:P1581 ?www.}
}
}
GROUP BY ?channel ?producer ?www ?description ?producerWD
ORDER BY DESC (?nrViewsTotal)
as a BubbleChart
edit#defaultView:BubbleChart
#title:Nr views of Outdoor gyms videos in Sweden per producer
SELECT ?producer
(sum(?nrviews) AS ?nrViewsTotal) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
{
?item p:P1651 ?Pyoutubev.
?Pyoutubev ps:P1651 ?youtubev.
OPTIONAL { ?Pyoutubev pq:P407 ?language. }
OPTIONAL { ?Pyoutubev pq:P5436 ?nrviews. }
?Pyoutubev pq:P2397 ?channel.
?producerWD wdt:P2397 ?channel.
OPTIONAL {
?producerWD rdfs:label ?producer.
FILTER((LANG(?producer)) = "sv")
}
OPTIONAL { ?producerWD wdt:P856 ?www. }
OPTIONAL { ?producerWD wdt:P1581 ?www. }
}
}
GROUP BY ?channel ?producer ?www
ORDER BY DESC (?nrViewsTotal)
Latest produced videos
edit#title:New Outdoor gyms videos produced in Sweden
SELECT ?publishedDate ?language (SAMPLE(?title) AS ?title) ?youtube (SAMPLE(?item) AS ?WD) (SAMPLE(?OutdoorGym) AS ?OutdoorGym) ?nrviews (SAMPLE(?admin) AS ?admin) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
OPTIONAL {
?item rdfs:label ?OutdoorGym.
FILTER((LANG(?OutdoorGym)) = "en")
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL {
?item wdt:P131 ?adminId.
?adminId rdfs:label ?admin.
FILTER((LANG(?admin)) = "en")
}
OPTIONAL { ?item wdt:P856 ?www. }
{
{?item p:P1651 ?Pyoutubev.
?Pyoutubev ps:P1651 ?youtubev.
OPTIONAL { ?Pyoutubev pq:P1810 ?title. }
OPTIONAL { ?Pyoutubev pq:P407 ?languageid.
?languageid rdfs:label ??language.
FILTER((LANG(?language)) = "en")
}
OPTIONAL { ?Pyoutubev pq:P5436 ?nrviews. }
OPTIONAL { ?Pyoutubev pq:P577 ?publishedDate. }
}
}
BIND(URI(CONCAT("https://www.youtube.com/watch?v=", ?youtubev)) AS ?youtube)
OPTIONAL { ?item wdt:P625 ?coord. }
}
GROUP BY ?youtube ?nrviews ?publishedDate ?language
ORDER BY DESC (?publishedDate)
BubbleChart Language of videos produced
edit#title:BubbleChart Language of videos produced for Sweden outdoorgyms
#defaultView:BubbleChart
SELECT ?language (COUNT(?item) AS ?nr) WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
{
?item p:P1651 ?Pyoutubev.
?Pyoutubev pq:P407 ?languageid.
?languageid (rdfs:label?) ?language.
FILTER((LANG(?language)) = "en")
}
}
GROUP BY ?language
ORDER BY DESC (?publishedDate)
Latest outdoor gyms created that has a Video
edit#title:Latest outdoor gyms created that has a Video
SELECT ?created ?itemLabel ?adminLabel ?youtube WHERE {
?item wdt:P6104 wd:Q107186275.
SERVICE wikibase:label {
bd:serviceParam wikibase:language "en,sv,de" .
}
OPTIONAL { ?item wdt:P18 ?img. }
OPTIONAL { ?item wdt:P131 ?admin. }
?item wdt:P1651 ?youtubev.
?item wdt:P571 ?created.
BIND(URI(CONCAT("https://www.youtube.com/watch?v=",?youtubev)) AS ?youtube)
OPTIONAL { ?item wdt:P625 ?coord. }
} order by desc(?created)
Nr views of Outdoor gyms videos in Sweden per producer
edit#title:Nr views of Outdoor gyms videos in Sweden per producer
SELECT ?producerWD ?producer ?description
(sum(?nrviews) AS ?nrViewsTotal)
(count(?nrviews) AS ?nrVideos) ?www WHERE {
?item wdt:P6104 wd:Q107186275;
wdt:P17 wd:Q34.
{
?item p:P1651 ?Pyoutubev.
?Pyoutubev ps:P1651 ?youtubev.
OPTIONAL { ?Pyoutubev pq:P407 ?language. }
OPTIONAL { ?Pyoutubev pq:P5436 ?nrviews. }
?Pyoutubev pq:P2397 ?channel.
?producerWD wdt:P2397 ?channel.
OPTIONAL {
?producerWD rdfs:label ?producer.
FILTER((LANG(?producer)) = "en")}
OPTIONAL{ ?producerWD schema:description ?description.
FILTER((LANG(?description)) = "en")
}
OPTIONAL { ?producerWD wdt:P856 ?www.}
OPTIONAL { ?producerWD wdt:P1581 ?www.}
}
}
GROUP BY ?channel ?producer ?www ?description ?producerWD
ORDER BY DESC (?nrViewsTotal)
SPARQL Wikicommons
editPicture gallery of images depicting a outdoor gym in this project Project Outdoor Gyms (Q107186275)
edit#title: Outdoor Gyms with pictures in Wikidata
#defaultView:ImageGrid{"hide":["?image "]}
SELECT DISTINCT ?itemLabel ?image ?www
WITH
{ SELECT ?item ?itemLabel ?itemDescription ?www WHERE
{ SERVICE <https://query.wikidata.org/sparql>
{?item wdt:P6104 wd:Q107186275.
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)
}
Picture gallery of images depicting a outdoor gym on a map
editAs Wikicommons now support Structured data ( video) and has its on Wikibase we can easy use SPARQL to query Wikicommons to find all pictures depicting an item in Wikidata that is a outdoor gym in this project....
#title: Outdoor Gyms with pictures in Wikidata
#defaultView:Map
SELECT DISTINCT ?itemLabel ?image ?www ?coord
WITH
{ SELECT ?item ?itemLabel ?itemDescription ?www ?coord WHERE
{ SERVICE <https://query.wikidata.org/sparql>
{?item wdt:P6104 wd:Q107186275.
OPTIONAL {?item wdt:P856 ?www}
OPTIONAL {?item wdt:P625 ?coord}
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)
}
Wikicommon latest dump
editStructured data on commons SPARQL endpoint is still in Beta and is reloaded every week. This query returns when it was last reloaded.
#title: Latest reload
select * { wikibase:Dump schema:dateModified ?s } ORDER BY DESC(?s) limit 1
Open Street Map
editSPARQL OSM sophox
edit- https://sophox.org/
- Fitness stations = 15 566 number fitness stations in the world on OSM
Most prolific mappers of fitness_station
edit#Most prolific mappers of fitness_station SELECT ?user (COUNT(*) AS ?count) WHERE { # Query OpenStreetMap for fitness_station and the users who last edited them ?fitness_station osmt:leisure "fitness_station"; 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 fitness_station
edit# leisure fitness_station in OSM #defaultView:Map SELECT DISTINCT ?osm ?coordinates WHERE { # Prevent optimizer from querying for everything tagged with wikidata=* before querying the service. hint:Query hint:optimizer "None" . # Query OpenStreetMap for leisure fitness_station ?osm osmt:leisure "fitness_station". # Get coordinates to display on a map ?osm osmm:loc ?coordinates. } ORDER BY ASC(?makeLabel)
Leisure fitness_station without a Wikidata tag
edit# leisure fitness_station in OSM with no Wikidata tag #defaultView:Map SELECT DISTINCT ?osm ?coordinates WHERE { # Prevent optimizer from querying for everything tagged with wikidata=* before querying the service. hint:Query hint:optimizer "None" . # Query OpenStreetMap for leisure fitness_station ?osm osmt:leisure "fitness_station". minus {?osm (osmt:wikidata) ?WD} # Get coordinates to display on a map ?osm osmm:loc ?coordinates. } ORDER BY ASC(?makeLabel)
Open street Map
editusing Overpass queries
Number of fitness_station in Sweden = area Sverige
edit[out:csv(::count, ::"count:nodes", ::"count:ways", ::"count:relations")] [timeout:125]; ( area["name"="Sverige"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="fitness_station"]; ); ); out count;
date | count | nodes | ways | relations |
---|---|---|---|---|
20210826 | 492 | 251 | 234 | 2 |
20210729 | 479 | 246 | 226 | 2 |
20210710 | 469 | 240 | 222 | 2 |
Number of Swedish fitness_station not connected to Wikidata
edit[out:csv(::count, ::"count:nodes", ::"count:ways", ::"count:relations")] [timeout:125]; area["name"="Sverige"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="fitness_station"][!"wikidata"]; ); out count;
date | count | nodes | ways | relations |
---|---|---|---|---|
20210826 | 179 | 89 | 89 | 1 |
20210801 | 182 | 91 | 89 | 2 |
20210731 | 195 | 103 | 90 | 2 |
20210730 | 264 | 135 | 127 | 2 |
20210729 | 300 | 160 | 138 | 2 |
20210710 | 320 | 166 | 147 | 2 |
same on a map - fitness_stations Sweden not connected to Wikidata
editarea["name"="Sverige"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="fitness_station"][!"wikidata"]; ); out meta;
same on a map - fitness_stations Sweden connected to Wikidata
editarea["name"="Sverige"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="fitness_station"]["wikidata"]; ); out meta;
Outdoor gyms Sweden
edit[out:json][timeout:25]; area["name"="Sweden"]->.boundaryarea; ( nwr(area.boundaryarea)["leisure"="fitness_station"]; ); out meta; [out:json][timeout:25];
- variant http://overpass-turbo.eu/s/1950
( // query part for: “leisure=fitness_station” node["leisure"="fitness_station"](Template:Bbox); way["leisure"="fitness_station"](Template:Bbox); relation["leisure"="fitness_station"](Template:Bbox); ); // print results out body; >; out skel qt;
leisure"="fitness_station" and Wikidata
edit( // query part for: “wikidata=* and leisure=fitness_station” node["wikidata"]["leisure"="fitness_station"](Template:Bbox); way["wikidata"]["leisure"="fitness_station"](Template:Bbox); relation["wikidata"]["leisure"="fitness_station"](Template:Bbox); ); // print results out body; >; out skel qt;
leisure"="fitness_station" not Wikidata
edit/* This has been generated by the overpass-turbo wizard. The original search was: “wikidata=* and "leisure"="fitness_station"” */ [out:json][timeout:25]; // gather results ( // query part for: “wikidata=* and leisure=fitness_station” node[!"wikidata"]["leisure"="fitness_station"](Template:Bbox); way[!"wikidata"]["leisure"="fitness_station"](Template:Bbox); relation[!"wikidata"]["leisure"="fitness_station"](Template:Bbox); ); // print results out body; >; out skel qt;