GSS-Cogs / ukstats.ccv2.theme

Climate Change v2 theme and content
Other
0 stars 0 forks source link

Update • Chart 4 – Annual mean temperature for the UK, England, Scotland, Wales and Northern Ireland, 1884 to 2020 - DB Climate and Weather #75

Closed peterfrenchons closed 1 year ago

peterfrenchons commented 1 year ago

Data published to PMD already. Need SPARQL query and figure updated

Shannon95 commented 1 year ago
PREFIX qb: <http://purl.org/linked-data/cube#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX scovo: <http://purl.org/NET/scovo#>
PREFIX sdmxa: <http://purl.org/linked-data/sdmx/2009/attribute#>
PREFIX geo: <http://statistics.data.gov.uk/def/statistical-geography#>

PREFIX meas: <http://purl.org/linked-data/cube#>
PREFIX data: <http://gss-data.org.uk/data/climate-change/met-office-regional-average-climate-observations-uk-annual-mean-temperature-2021/regional-average-climate-observations-uk-annual-mean-temperature-2021#>
PREFIX dim: <http://gss-data.org.uk/data/climate-change/met-office-regional-average-climate-observations-uk-annual-mean-temperature-2021/regional-average-climate-observations-uk-annual-mean-temperature-2021#dimension/>
PREFIX measmean: <http://gss-data.org.uk/data/climate-change/met-office-regional-average-climate-observations-uk-annual-mean-temperature-2021/regional-average-climate-observations-uk-annual-mean-temperature-2021#measure/>
PREFIX area: <http://purl.org/linked-data/sdmx/2009/dimension#>

SELECT* {
            {
                SELECT DISTINCT ?locationEdit ?date ?temp ?measure ?unit 
                    WHERE {
                        ?obs qb:dataSet data:dataset ;
                             measmean:annual-mean-temperature ?temp;
                meas:measureType [ rdfs:label ?measure ] ;
                             dim:year [ rdfs:label?date ];
                             area:refArea ?location ;
                             sdmxa:unitMeasure [ rdfs:label ?unit ];

              OPTIONAL{?location geo:officialname ?locationEdit}
              FILTER(?locationEdit IN ("United Kingdom", "England", "Northern Ireland", "Scotland", "Wales")) .
                      }         
           }
           UNION 
                {
                    # Long term average between 1961 and 2010
                    SELECT DISTINCT ?locationEdit ?date ?temp ?measure ?unit
                    WHERE {
                        ?obs qb:dataSet data:dataset ;
                            dim:year [ rdfs:label ?date ];

                        BIND("1961 to 1990 long-term average" AS ?locationEdit)
            BIND("Annual Mean Temperature" AS ?measure)
            BIND("Degrees centigrade" AS ?unit)

                        {
                            SELECT (ROUND(AVG(?value)*10)/10 AS ?temp)
                            WHERE {
                                ?obs qb:dataSet data:dataset ;
                                     measmean:annual-mean-temperature ?value;
                                     dim:year [ rdfs:label ?date ];
                                     area:refArea ?location ;

                  OPTIONAL{?location geo:officialname ?locationEdit}
                                  FILTER(?locationEdit IN ("United Kingdom", "England", "Northern Ireland", "Scotland", "Wales")) .
                                   FILTER(?date >= "1961" && ?date <= "1990") .

                            }
                        }
                    }
                }
        UNION
                {
                    # Long term average between 1991 and 2020
                    SELECT DISTINCT ?locationEdit ?date ?temp ?measure ?unit
                    WHERE {
                        ?obs qb:dataSet data:dataset ;
                            dim:year [ rdfs:label ?date ];

                            BIND("1991 to 2020 long-term average" AS ?locationEdit)
               BIND("Annual Mean Temperature" AS ?measure)
               BIND("Degrees centigrade" AS ?unit)

                        {
                            SELECT (ROUND(AVG(?value)*10)/10 AS ?temp)
                            WHERE {
                                ?obs qb:dataSet data:dataset ;
                                        measmean:annual-mean-temperature ?value;
                                        dim:year [ rdfs:label ?date ];
                                        area:refArea ?location ;

                   OPTIONAL{?location geo:officialname ?locationEdit}
                                FILTER(?locationEdit IN ("United Kingdom", "England", "Northern Ireland", "Scotland", "Wales")) .
                                FILTER(?date >= "1991" && ?date <= "2020") .
                            }
                        }
                    }
                }
}
ORDER BY ASC(?date) ?locationEdit
Shannon95 commented 1 year ago

An updated SPARQL query using the new dataset has been created and loads in data as expected up to 2021.

This will allow for the chart (Climate and Weather fig 4) to be updated with the latest data source, which can be found here: Regional average climate observations, UK annual mean temperature 2021

Please find the query created under Home/Dashboards/Climate and weather with the name SPARQL - Annual mean temperature (°C) for the UK, England, Scotland, Wales and Northern Ireland, 1884 to 2021 : 2022-11-23 or click here.

SPARQL query in the above comment for reference.