Wikidata:WikiProject Weather observations/SPARQL

in English

Requêtes SPARQL reliées aux weather station (Q190107) du Meteorological Service of Canada (Q349450).

Toutes les stations météo de Wikidata edit

# Toutes les stations
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Toutes les stations du SMC edit

# Toutes les stations du SMC
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P127 wd:Q349450.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }

}
Try it!

Note: les trois stations suivantes sont localisées à 0° de longitude et latitude car c'est ce qui est indiqué dans le fichier du SMC:

encore en fonction edit

# Toutes les stations du SMC encore en fonction
#defaultView:Map
SELECT ?item ?itemLabel ?coord 
WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P127 wd:Q349450.

  OPTIONAL { ?item wdt:P3999 ?closureDate }
  FILTER(# Closure date is not set
    !BOUND(?closureDate)    
  )
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

fermées edit

# Toutes les stations du SMC fermées
#defaultView:Map
SELECT ?item ?itemLabel ?coord 
WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P127 wd:Q349450.

  # Closure date exists and is before 2100
  ?item wdt:P3999 ?closureDate . 
  FILTER (?closureDate < "2100-01-01T00:00:00Z"^^xsd:dateTime) .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations du SMC par altitude edit

altitude par groupe de 500 m. edit

#Stations du SMC par altitude, par groupe de 500 m.
#defaultView:Map
SELECT ?item ?itemLabel ?coord ?altitude ?layer WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107 ; wdt:P127 wd:Q349450 ; wdt:P2044 ?altitude .
  BIND (FLOOR(?altitude/500) AS ?layer )
  ?item wdt:P625 ?coord.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
Try it!

altitude > 1000 m edit

# Stations du SMC altitude > 1000 m
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.

  ?item wdt:P2044 ?altitude.
  FILTER (?altitude > 1000) .

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
  ?item wdt:P127 wd:Q349450.
}
Try it!

Stations du SMC de la ligne avancée d'alerte précoce (latitudes [64°57', 70°45'] N) edit

# Stations du SMC entre les latitudes [66°34', 70°45'] N 
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P127 wd:Q349450.
  
  ?item p:P625 ?coordinate .
  ?coordinate psv:P625 ?coordinate_node .
  ?coordinate_node wikibase:geoLatitude ?lat .
  ?coordinate_node wikibase:geoLongitude ?lon .

  FILTER (?lat > 66.56)
  FILTER (?lat < 70.45)
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }

}
Try it!

Stations du Nouveau-Brunswick edit

# Stations météo du Nouveau-Brunswick
#defaultView:Map

# "CANADA": "Q16"
# "ALBERTA":"Q1951",
# "COLOMBIE-BRITANNIQUE":"Q1974",
# "ILE DU PRINCE-EDOUARD":"Q1979",
# "MANITOBA":"Q1948",
# "NOUVEAU-BRUNSWICK":"Q1965",
# "NOUVELLE-ECOSSE":"Q1952",
# "NUNAVUT":"Q2023",
# "ONTARIO":"Q1904",
# "QUEBEC":"Q176",
# "SASKATCHEWAN":"Q1989",
# "TERRE-NEUVE":"Q2003",
# "TERRITOIRES DU NORD-OUEST":"Q2007",
# "YUKON":"Q2009"

SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1965 .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }

}
Try it!

Stations NB classées par date de mise en service edit

# Stations NB classées par date de mise en service
SELECT ?item ?itemLabel ?coord ?date_de_mise_en_service WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1965.

  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
  OPTIONAL { ?item wdt:P729 ?date_de_mise_en_service. }
}
ORDER BY DESC(?date_de_mise_en_service)
Try it!

Stations du NB avec observations horaires edit

# Stations NB obs horaires
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1965 .
  ?item wdt:P6339 wd:Q59657010 . # Hourly:Q59657010  Daily: Q59657036  Monthly: Q59657037
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations du NB avec obs horaire [1975,2000] edit

# Stations NB obs horaires entre [1975, 2000]
#defaultView:Map
SELECT ?item ?itemLabel ?coord ?starttime ?endtime WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1965 .
  ?item wdt:P6339 wd:Q59657010 .
  ?item p:P6339 ?daily_obs .
  ?daily_obs pq:P580 ?starttime.
  ?daily_obs pq:P582 ?endtime.
  FILTER (?starttime < "1975-01-02T00:00:00Z"^^xsd:dateTime) .
  FILTER (?endtime > "2000-01-01T00:00:00Z"^^xsd:dateTime) .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations du Québec créées avant 1920 edit

# Stations du Québec créées avant 1920
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q176 .
  ?item wdt:P729 ?service_entry . 
  FILTER (?service_entry < "1920-01-01T00:00:00Z"^^xsd:dateTime) .
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations de Nouvelle-Écosse fermées depuis 1980 edit

# Stations de Nouvelle-Écosse fermées depuis 1980
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1952 .
  ?item wdt:P3999 ?closureDate . 
  FILTER (?closureDate > "1980-01-01T00:00:00Z"^^xsd:dateTime) .
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations d'Ontario actives en 1953 edit

# Stations d'Ontario actives en 1953 
#defaultView:Map
SELECT ?item ?itemLabel ?coord 
WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1904 .

  ?item wdt:P729 ?service_entry . 
  # service entry is before 1953
  FILTER (?service_entry <= "1953-01-01T00:00:00Z"^^xsd:dateTime) .
  # and closure date not before 1953
  OPTIONAL { ?item wdt:P3999 ?closureDate }
  FILTER(
    # Closure date is not set
    ?closureDate > "1953-01-01T00:00:00Z"^^xsd:dateTime|| !BOUND(?closureDate)     # or closure date is after 1953
  )
 
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
Try it!

}

fermées par la suite edit

# Stations d'Ontario actives en 1953 et fermées par la suite
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1904 .

  ?item wdt:P729 ?service_entry . 
  FILTER (?service_entry <= "1953-01-01T00:00:00Z"^^xsd:dateTime) .

  ?item wdt:P3999 ?closureDate . 
  FILTER (?closureDate > "1953-01-01T00:00:00Z"^^xsd:dateTime) .
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

toujours en fonction edit

# Stations d'Ontario actives en 1953 et toujours en fonction
#defaultView:Map
SELECT ?item ?itemLabel ?coord 
WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q1904 .

  ?item wdt:P729 ?service_entry . 
  FILTER (?service_entry <= "1953-01-01T00:00:00Z"^^xsd:dateTime) .
  # ... but the statement has no P3999 (end date) qualifier
  FILTER NOT EXISTS { ?item wdt:P3999 ?x }  
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations de Terre-Neuve-et-Labrador fermées en 2017 edit

# Stations de Terre-Neuve-et-Labrador fermées en 2017
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P131 wd:Q2003 .
  ?item wdt:P3999 ?closureDate . 
  FILTER (?closureDate = "2017-01-01T00:00:00Z"^^xsd:dateTime) .
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations du Canada fermées en 2017 et 2018 edit

# Stations du Canada fermées en 2017 et 2018
#defaultView:Map
SELECT ?item ?itemLabel ?coord WHERE {
  ?item (wdt:P31/wdt:P279*) wd:Q190107.
  ?item wdt:P127 wd:Q349450.
  ?item wdt:P3999 ?closureDate . 
  FILTER (?closureDate = "2017-01-01T00:00:00Z"^^xsd:dateTime ||
         ?closureDate = "2018-01-01T00:00:00Z"^^xsd:dateTime) .
   
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?item wdt:P625 ?coord. }
}
Try it!

Stations < 10km edit

d'une ville au NB edit

# Stations du NB < 10km d'une ville
#defaultView:Map
SELECT DISTINCT ?station ?coordonn_es_g_ographiques WHERE {
  {
    # City/town: Q7930989  Airport: Q1248784 Port: Q44782
    SELECT ?city WHERE { ?city (wdt:P31/wdt:P279*) wd:Q7930989. }
  }
  ?city wdt:P131* wd:Q1965. # In NB
   
  ?city wdt:P625 ?cityLoc # Cities location
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?cityLoc .
    bd:serviceParam wikibase:radius "10" . # within 10 km radius
  } .
   # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?station wdt:P625 ?coordonn_es_g_ographiques. }
}
Try it!

d'un port au Canada edit

# Stations < 10km d'un port au Canada
#defaultView:Map
SELECT DISTINCT ?station ?coordonn_es_g_ographiques WHERE {
  ?port wdt:P31 wd:Q44782.
  ?port wdt:P17 wd:Q16.
    
  ?port wdt:P625 ?portLoc # Port location
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?portLoc .
    bd:serviceParam wikibase:radius "10" . # within 10 km radius
  } .
   # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?station wdt:P625 ?coordonn_es_g_ographiques. }
}
Try it!

d'un aéroport au Canada edit

# Stations < 10km d'un aéroport au Canada (y a beaucoup d'aéroports au Canada)
#defaultView:Map
SELECT DISTINCT ?station ?coordonn_es_g_ographiques WHERE {

  # City/town: Q7930989  Airport: Q1248784 Port: Q44782
  ?aeroport wdt:P31 wd:Q1248784.
  ?aeroport wdt:P17 wd:Q16.
    
  ?aeroport wdt:P625 ?aeroportLoc # Aeroport locations
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?aeroportLoc .
    bd:serviceParam wikibase:radius "10" . # within 10 km radius
  } .
   # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?station wdt:P625 ?coordonn_es_g_ographiques. }
}
Try it!

d'un inondation au Canada edit

# Stations < 10km d'un inondation au Canada
#defaultView:Map
SELECT DISTINCT ?station ?coordonn_es_g_ographiques WHERE {
  ?inondation wdt:P31 wd:Q8068.
  ?inondation wdt:P17 wd:Q16.
    
  ?inondation wdt:P625 ?inonLoc # Inondation location
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?inonLoc .
    bd:serviceParam wikibase:radius "10" . # within 10 km radius
  } .
   # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?station wdt:P625 ?coordonn_es_g_ographiques. }
}
Try it!

Stations en Ontario à moins de 10 km d'une ville de plus de 100 000 habitants edit

# Stations en Ontario dans un rayon de 10 km d'une ville de plus de 100 000 habitants
#defaultView:Map
SELECT DISTINCT ?city ?coordonn_es_g_ographiques WHERE {
  {
    # City/town: Q7930989  Airport: Q1248784 Port: Q44782
    SELECT ?city WHERE { ?city (wdt:P31/wdt:P279*) wd:Q7930989. }
  }
  ?city wdt:P131* wd:Q1904. # In Ontario
   
  # Filtering by population
  ?city wdt:P1082 ?population # Cities population
  FILTER (?population > 100000) .
  
  # Filtering by location
  ?city wdt:P625 ?cityLoc # Cities location
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?cityLoc .
    bd:serviceParam wikibase:radius "10" . # within 10 km radius
  } .
   # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?city wdt:P625 ?coordonn_es_g_ographiques. }
}
Try it!

Stations QC à moins de 1km d'un pont d'une longueur supérieure à 100 m edit

# Stations QC dans un rayon de 1km d'un pont d'une longueur supérieure à 100 m 
#defaultView:Map
SELECT DISTINCT ?station ?coordonn_es_g_ographiques WHERE {
  
  # Bridges
  {
    SELECT ?bridge WHERE { ?bridge (wdt:P31/wdt:P279*) wd:Q12280. }
  }
  ?bridge wdt:P131* wd:Q176. # in QC
  
  # with a length < 100 m
  ?bridge wdt:P2043 ?length.
  FILTER(?length > 100)
          
  # Find station within 1km of these bridges 
  ?bridge wdt:P625 ?bridgeLoc 
  SERVICE wikibase:around {
    ?station wdt:P625 ?location .
    bd:serviceParam wikibase:center ?bridgeLoc .
    bd:serviceParam wikibase:radius "1" . # within 1 km radius
  } .
  # is close from a Wx station
  FILTER EXISTS { ?station wdt:P31/wdt:P279* wd:Q190107 } .
  
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
  OPTIONAL { ?station wdt:P625 ?coordonn_es_g_ographiques. }
}
Try it!

Requête pour mise à jour edit

Fonctionne comme argument du le script MSC Weather Stations to Wikidata pour la mise à jour des stations.


PREFIX schema: <http://schema.org/>

# Information sur les stations météo du SMC
SELECT ?station ?label_en ?description_en ?label_fr ?description_fr ?instance_of ?coordinate_location ?province_label ?identifiant_WIGOS_de_station ?property_of ?start_date ?end_date ?msc_climate_id ?altitude ?data_interval ?hourly ?h_start ?h_end ?daily ?d_start ?d_end ?monthly ?m_start ?m_end WHERE {
  ?station (wdt:P31/wdt:P279*) wd:Q190107.
  ?station wdt:P17 wd:Q16.
  ?station wdt:P6242 ?MSCID

  # Data interval (HLY, DLY, MLY)
  OPTIONAL { ?station p:P6339 ?data_interval . }
  OPTIONAL { ?station p:P6339 ?d_interval .          # there is a P6339 property
             ?d_interval ps:P6339 wd:Q59657036 .  # and it's a daily
             ?d_interval ps:P6339 ?daily .        # and we get its value, in case there are no dates
             OPTIONAL { ?d_interval pq:P580 ?d_start .} # might be a start date
             OPTIONAL { ?d_interval pq:P582 ?d_end .}   # might be an end date
  }
  OPTIONAL { ?station p:P6339 ?m_interval .          # there is a P6339 property
             ?m_interval ps:P6339 wd:Q59657037 .  # and it's monthly
             ?m_interval ps:P6339 ?monthly .        # and we get its value, in case there are no dates
             OPTIONAL { ?m_interval pq:P580 ?m_start .} # might be a start date
             OPTIONAL { ?m_interval pq:P582 ?m_end .}   # might be an end date
  }
  OPTIONAL { ?station p:P6339 ?h_interval .          # there is a P6339 property
             ?h_interval ps:P6339 wd:Q59657010 .  # and it's hourly
             ?h_interval ps:P6339 ?hourly .        # and we get its value, in case there are no dates
             OPTIONAL { ?h_interval pq:P580 ?h_start .} # might be a start date
             OPTIONAL { ?h_interval pq:P582 ?h_end .}   # might be an end date
  }

  OPTIONAL { ?station wdt:P31 ?instance_of. }
  OPTIONAL { ?station wdt:P625 ?coordinate_location. }
  OPTIONAL { ?station wdt:P131 ?province_label. }
  OPTIONAL { ?station wdt:P4136 ?identifiant_WIGOS_de_station. }
  OPTIONAL { ?station wdt:P127 ?property_of. }
  OPTIONAL { ?station wdt:P729 ?start_date. }
  OPTIONAL { ?station wdt:P3999 ?end_date. }
  OPTIONAL { ?station wdt:P6242 ?msc_climate_id. }
  OPTIONAL { ?station wdt:P2044 ?altitude. }
  
  
  # FR/EN description
  OPTIONAL { ?station rdfs:label ?label_en. }
  OPTIONAL { ?station rdfs:label ?label_fr. }
  OPTIONAL { ?station schema:description ?description_en. }
  OPTIONAL { ?station schema:description ?description_fr. }
  FILTER((LANG(?label_en)) = "en")
  FILTER((LANG(?label_fr)) = "fr")
  FILTER((LANG(?description_en)) = "en")
  FILTER((LANG(?description_fr)) = "fr")

}
ORDER BY(?MSCID)
Try it!