Spatial aggregation is the process of computing regional statistics (e.g., means, sums) from gridded (NetCDF) climate or energy indicators. These gridded datasets typically cover the globe at uniform spatial resolution (e.g., 0.25° or 1.00°). Spatial aggregation enables users to derive regional statistics over standard administrative areas, supporting downstream climate or energy analyses.
Two levels of spatial aggregation are supported:
ADMIN0 (ADM0): Country-level administrative units (national level);
ADMIN1 (ADM1): First-level subdivisions within countries (e.g., states, provinces, or regions).
This enables analyses at multiple scales of governance. The administrative zones used for aggregation are derived from standard shapefiles (e.g., Natural Earth), and are shown in Figure 1.1.


Figure 1.1: Global administrative regions used for spatial aggregation.
Top: ADM0 (country-level boundaries).
Bottom: ADM1 (first-level subdivisions such as states or provinces).
The spatial aggregation procedure transforms gridded climate or energy indicators into regional averages or totals over predefined administrative areas (ADM0 and ADM1). This is achieved through a two-step process: the generation of the regional floating masks and the application of those masks to average the data.
Each administrative unit (country or subnational region) is associated with a spatial mask, created using the corresponding ADM0 or ADM1 shapefile. The steps for generating the float masks are:
Identification of intersecting grid cells: All grid cells whose centers or extents intersect with a region's boundary are identified. These include fully enclosed cells and partially overlapping ones along borders or coastlines.
Border correction: For partially overlapping cells, the fraction of the grid cell that lies within the region is computed. This is done using geometric intersection between the polygon and the cell area.
Land-sea weighting: In parallel, each grid cell is assigned a land fraction value using the ERA5 land-sea mask. This accounts for ocean coverage, internal water bodies, or coastal configurations.
Final weighting assignment:
For border cells, the intersection fraction from Step 2 is used as the weight.
For interior cells, the land-sea mask value from Step 3 is applied.
If a cell is not intersected at all or has 0 land fraction, it is excluded.
This results in a fractional float mask with weights between 0 and 1 for each region and grid cell. These masks match the spatial resolution of the input gridded data and are precomputed to speed up the aggregation process.
Figure 2.1 illustrates an example of such a float mask for Italy at ADM0 level, showing how coastal and border grid cells are fractionally weighted.
Figure 2.1: Example of a float mask for the Italian ADM0 administrative region, showing fractional grid cell coverage along borders and coastlines.
Once the float masks are computed, spatial aggregation is carried out as follows:
Input Data
Gridded climate or energy indicators in NetCDF format.
Precomputed fractional masks for each administrative region (ADM0 or ADM1).
Optional: additional exclusion masks (e.g., to remove high-slope areas or restricted zones). Please refer to Exclusion Areas Computation for more information.
Mask Application and Aggregation Steps
For each time step and administrative region:
Multiply the gridded data by:
The corresponding regional float mask.
The cosine of latitude, to account for the decreasing surface area of grid cells at higher latitudes.
Any additional optional exclusion masks (if used).
Sum the weighted values across all grid cells assigned to the region.
Normalise the result:
For mean-type indicators (e.g., temperature, wind speed): divide by the sum of weights (mask × cosine).
For sum-type indicators (e.g., precipitation, solar radiation): return the unnormalised total, as it reflects accumulation over time.
Handling of Missing Data
Grid cells with missing or masked values are automatically excluded from the aggregation.
Aggregation for a region is skipped or flagged if fewer than a minimum percentage (typically 80%) of its grid cells contain valid data.
The final outputs are regional time series, provided in CSV format, with rows corresponding to time steps and columns to administrative units. The following information is included:
Region identifier (e.g., ISO country code or ADM1 name)
Timestamp (hour, day, month, depending on input resolution)
Aggregated value for each indicator
The temporal resolution of the output matches that of the input gridded dataset.
For the Energy Degree Days (EDD) indicator—used as a proxy for energy demand—an adapted spatial aggregation method is employed to account for population distribution more accurately, particularly in coastal areas.
EDD is computed from Heating Degree Days (HDD) and Cooling Degree Days (CDD), both of which are weighted by population to reflect real energy demand (please refer to Electricity and Energy Demand Models for more information).
In contrast to purely land-based indicators, this requires precise representation of population centers, many of which are located in coastal regions.
Standard land-sea masks tend to partially exclude grid cells that fall over water—even if they include densely populated coastal zones. This exclusion could result in underestimating the energy demand of countries with large coastal populations.
To overcome this, grid cells that intersect a country’s administrative boundary are fully assigned to that country, even if partially over the sea. This ensures that population-weighted averages include all relevant urban areas near the coast. This adjustment is critical for countries like Italy, Japan, or the Netherlands, where a significant portion of the population resides in coastal cities.
Figure 2.2 shows an example of this modified float mask, where all coastal-intersecting grid cells are fully assigned to the Italian national boundary, regardless of sea overlap.
Figure 2.2: Modified float mask for the Italian ADM0 region used in the aggregation of Energy Degree Days (EDD).
All grid cells intersecting national boundaries—including those partially over the sea—are fully attributed to the country to preserve accuracy in population-weighted energy demand estimates, particularly in coastal zones.
This document has been produced in the context of the Copernicus Climate Change Service (C3S). The activities leading to these results have been contracted by the European Centre for Medium-Range Weather Forecasts, operator of C3S on behalf of the European Union (Delegation Agreement signed on 11/11/2014 and Contribution Agreement signed on 22/07/2021). All information in this document is provided "as is" and no guarantee or warranty is given that the information is fit for any particular purpose. The users thereof use the information at their sole risk and liability. For the avoidance of all doubt , the European Commission and the European Centre for Medium - Range Weather Forecasts have no liability in respect of this document, which is merely representing the author's view. |
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.