User:Bouzinac/Recherches géographiques
List all elements close to a wikielement edit
Add #defaultView:Map pour avoir la carte
SELECT ?place ?placeLabel ?location ?instanceLabel ?dist WHERE {
wd:Q7901873 wdt:P625 ?loc .
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?loc .
bd:serviceParam wikibase:radius 10 . # in kilometers
}
OPTIONAL {
?place wdt:P31 ?instance .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
BIND(geof:distance(?loc, ?location) AS ?dist) .
} ORDER BY ASC(?dist)
List all elements close to a GPS point edit
#defaultView:Map
SELECT ?place ?placeLabel ?location ?instanceLabel ?dist WHERE {
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center "Point(24.71304 10.2059)"^^geo:wktLiteral .
bd:serviceParam wikibase:radius 30 . # in kilometers
}
OPTIONAL {
?place wdt:P31 ?instance .
}
SERVICE wikibase:label { bd:serviceParam wikibase:language 'en' }
BIND(geof:distance(?loc, ?location) AS ?dist) .
} ORDER BY ASC(?dist)
Elements that are inside a rectangle (East/West/North/South) edit
#defaultView:Map
SELECT ?item ?country ?coord {
VALUES ?country { wd:Q258 } . #select a country here, works also with any item having east, west, south and north bounds
?country p:P1332 [ ps:P1332 ?north; psv:P1332 ?nValue ];
p:P1333 [ ps:P1333 ?south; psv:P1333 ?sValue ];
p:P1334 [ ps:P1334 ?east; psv:P1334 ?eValue ];
p:P1335 [ ps:P1335 ?west; psv:P1335 ?wValue ].
?nValue wikibase:geoLatitude ?nLat . hint:Prior hint:rangeSafe true .
?sValue wikibase:geoLatitude ?sLat . hint:Prior hint:rangeSafe true .
?eValue wikibase:geoLongitude ?eLon . hint:Prior hint:rangeSafe true .
?wValue wikibase:geoLongitude ?wLon . hint:Prior hint:rangeSafe true .
?item p:P625 [ a wikibase:BestRank; ps:P625 ?coord; psv:P625 ?cValue ] .
?cValue wikibase:geoLatitude ?lat . hint:Prior hint:rangeSafe true .
?cValue wikibase:geoLongitude ?lon . hint:Prior hint:rangeSafe true .
?cValue wikibase:geoGlobe ?globe . hint:Prior hint:rangeSafe true .
BIND(COALESCE(?globe,wd:Q2) as ?Globe)
FILTER (?Globe =wd:Q2) #select only Earth-like coordinates
MINUS { ?item wdt:P17 [] } . #has the item any P17 value ?
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q4830453. } # exclude ENTREPRISES
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q15893266. } # exclude old entities
MINUS { ?item wdt:P576 _:b2. } # remove items with P576 (dissolved, abolished or demolished) as a main property
FILTER( ?sLat < ?lat && ?lat < ?nLat ) . #modify here to
FILTER( ?wLon < ?lon && ?lon < ?eLon ) .
} limit 100
Elements that are close from a centroïd of a country edit
#defaultView:Map
SELECT ?item ?country ?coord ?dist {
hint:Query hint:optimizer "None" .
VALUES ?country { wd:Q40 } .
OPTIONAL{?country wdt:P5140 ?centerGeog .}
OPTIONAL{?country wdt:P625 ?Coords .}
BIND(COALESCE(?centerGeog,?Coords) as ?center)
SERVICE wikibase:around {
?item wdt:P625 ?coord .
bd:serviceParam wikibase:center ?center .
bd:serviceParam wikibase:radius "50" .
bd:serviceParam wikibase:distance ?dist .
bd:serviceParam wikibase:geoGlobe ?globe .
} .
BIND(COALESCE(?globe,wd:Q2) as ?Globe)
FILTER (?Globe =wd:Q2)
MINUS { ?item wdt:P17 [] } .
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q4830453. } # exclude ENTREPRISES
MINUS { ?item (wdt:P31/wdt:P279*) wd:Q15893266. } # exclude old entities
MINUS { ?item wdt:P576 _:b2. } # remove items with P576 (dissolved, abolished or demolished) as a main property
} ORDER BY ?dist
Buildings that are not a part of a bounding box covering the mainland of a country edit
#title:Buildings that are not a part of a bounding box covering the mainland of a country
#defaultView:Map
SELECT ?item ?itemLabel ?coords WITH { SELECT * WHERE {
VALUES ?country { wd:Q258 } # change your country here, check that the bounding box only covers its mainland
?country p:P1332 [ a wikibase:BestRank; psv:P1332 [ wikibase:geoLatitude ?nmp_lat ] ].
?country p:P1333 [ a wikibase:BestRank; psv:P1333 [ wikibase:geoLatitude ?smp_lat ] ].
?country p:P1334 [ a wikibase:BestRank; psv:P1334 [ wikibase:geoLongitude ?emp_long ] ].
?country p:P1335 [ a wikibase:BestRank; psv:P1335 [ wikibase:geoLongitude ?wmp_long ] ].
} } AS %a WITH { SELECT distinct ?item ?coords
WHERE {
INCLUDE %a
?item wdt:P17 ?country;
wdt:P31/wdt:P279* wd:Q811979#architectural thing
;wdt:P625 ?coords;#its coordinates
p:P625 [ a wikibase:BestRank; psv:P625 ?coord_vn ] .
?coord_vn wikibase:geoLatitude ?lat. hint:Prior hint:rangeSafe true.
?coord_vn wikibase:geoLongitude ?long. hint:Prior hint:rangeSafe true.
FILTER(?lat > ?nmp_lat || ?lat < ?smp_lat || ?long > ?emp_long || ?long < ?wmp_long)
}
LIMIT 10000#change values here, small value if big country eg 250, bigger value if medium country, huge value if very small country
} AS %b WHERE { INCLUDE %a INCLUDE %b
# Try to remove things here to ensure it runs after named subquery b
FILTER NOT EXISTS { ?item wdt:P17 ?country2. FILTER(?country2 != ?country ) }
MINUS { ?item wdt:P5816 wd:Q19860854. } MINUS { ?item (wdt:P576|wdt:P3999) ?dispar. }#on ne veut pas les disparus
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .} }
List all wiki elements with coordinates, close to a geographic center of a an element edit
#defaultView:List
SELECT ?place ?placeLabel ?location
WHERE
{
wd:Q940798 wdt:P625 ?centerLoc .
SERVICE wikibase:around {
?place wdt:P625 ?location .
bd:serviceParam wikibase:center ?centerLoc .
bd:serviceParam wikibase:radius "250" .
} .
MINUS { ?place wdt:P17 wd:Q142 }
SERVICE wikibase:label {
bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" .
}
}
Max East/West/North/South for each country edit
SELECT distinct ?pays ?paysLabel ?coord_max_nord ?coord_max_sud ?coord_max_ouest ?coord_max_est WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?pays wdt:P31 wd:Q6256.
OPTIONAL { ?pays wdt:P1332 ?coord_max_nord. }
OPTIONAL { ?pays wdt:P1333 ?coord_max_sud. }
OPTIONAL { ?pays wdt:P1335 ?coord_max_ouest. }
OPTIONAL { ?pays wdt:P1334 ?coord_max_est. }
MINUS { ?pays wdt:P576 _:b2. }
MINUS { ?pays wdt:P582 _:b3. }
}order by ?paysLabel
Stops in straight line edit
SELECT ?item ?itemLabel ?coords ?dist WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
?item wdt:P81 wd:Q18165631; wdt:P625 ?coords.
filter(?item not in(wd:Q112825155))
VALUES ?station { wd:Q112823670 } . #select a station here, works also with any item having east, west, south and north bounds
?station p:P625 [ a wikibase:BestRank; ps:P625 ?coord_cible; psv:P625 ?cibleValue ] .
?cibleValue wikibase:geoLatitude ?lat_cible . hint:Prior hint:rangeSafe true .
?cibleValue wikibase:geoLongitude ?lon_cible . hint:Prior hint:rangeSafe true .
?item p:P625 [ a wikibase:BestRank; ps:P625 ?coord; psv:P625 ?cValue ] .
?cValue wikibase:geoLatitude ?lat . hint:Prior hint:rangeSafe true .
?cValue wikibase:geoLongitude ?lon . hint:Prior hint:rangeSafe true .
#FILTER( ?lat_cible > ?lat ) . #modify here to
FILTER( ?lon_cible < ?lon ) .
wd:Q112823927 wdt:P625 ?Burnley_St_Victoria_St_coord .
BIND(geof:distance(?Burnley_St_Victoria_St_coord, ?coords) as ?dist)
}
ORDER BY ?dist
Items inside an geo box edit
SELECT ?place ?placeLabel ?location ?continent WHERE {
SERVICE wikibase:box {
?place wdt:P625 ?location .
bd:serviceParam wikibase:cornerSouthWest "Point(136 -90)"^^geo:wktLiteral .
bd:serviceParam wikibase:cornerNorthEast "Point(142 -60)"^^geo:wktLiteral .
}
OPTIONAL { ?place wdt:P30 ?continent }
SERVICE wikibase:label { bd:serviceParam wikibase:language "fr,en". }
}