User:Bouzinac/Recherches géographiques

List all elements close to a wikielementEdit

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)

Try it!

List all elements close to a GPS pointEdit

#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)

Try it!

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

Try it!

Elements that are close from a centroïd of a countryEdit

#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

Try it!

List all wiki elements with coordinates, close to a geographic center of a an elementEdit

#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" .
} 
}

Try it!

Max East/West/North/South for each countryEdit

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

Try it!