# Parallel Processing Strategies for Geospatial Data in a Cloud Computing Infrastructure
## 3 Workflow: Spatial Aggregation  
With the new Common Agriculture Policy (CAP) implementation for 2023-2027 [17], there is an important shift from a controlling approach based on sampling to monitoring each agricultural parcel. Satellite images from the Copernicus program are available with a spatial resolution of up to 10 m (Sentinel-2), which allows the extraction of sufficiently detailed information at the average parcel level. Meanwhile, with the two-satellite constellations (A and B), revisit times of 2-3 days can be obtained thanks to large overlapsbetween the swaths originating from adjacent orbits of the satellites. Even for the cloudy conditions in most parts of central and western Europe, this allows time series to be obtained to characterize the phenology of different crop types along the agronomic year for each agricultural parcel. An index that is often used for vegetation applications is the normalized difference vegetation index (NDVI). It expresses the greenness of vegetation and is based on the reflectance values in the red and near-infrared (NIR) parts of the electromagnetic spectrum. The surface reflectance can be derived from the Sentinel-2 satellite acquisitions and are available for download as level 2A products (bottom of atmosphere surface reflectance) [18]. The Sentinel-2 surface reflectance value for a pixel at position \((x,y)\), acquisition time \(t\), and for the spectral band \(b\) can be represented as a data cube in four dimensions:  
\[cube(x,y,t,b). \tag{5}\]  
The NDVI for a pixel at position \((x,y)\) and at acquisition time \(t\) can then be calculated as a function from of the data cube as follows:  
\[\text{NDVI}(x,y,t)=\frac{cube(x,y,t,NIR)-cube(x,y,t,red)}{cube(x,y,t,NIR)+ cube(x,y,t,red)}. \tag{6}\]  
The time series of NDVI derived from Sentinel-2 can be used for phenology retrieval [19], crop monitoring, crop identification, and investigating crop rotations or other agricultural practices [20]. However, the amount of data to be processed can be an obstacle for European Union (EU) member states that will implement the new CAP monitoring system. With an efficient extraction tool that aggregates the pixel information at the parcel level as a cloud service, this task can be greatly simplified. Instead of dealing with massive amounts of pixel data of varying quality (e.g., due to cloud cover), member states obtain spatially aggregated and filtered time series \(N(t,p)\) at the parcel level (\(p\)) that can be analyzed locally. When the pixel values within the parcels are spatially aggregated by calculating the mean of the NDVI values for each of the 71 images for all the Sentinel-2 acquisitions in 2020, a time series NDVI at the parcel level \(p\) is obtained, as shown in Figure 1.  
An implementation of the spatial aggregation is presented in pseudocode in Algorithm 1. The algorithm starts by initializing a data cube from a Sentinel-2 collection, processed to level 2A. The collection is filtered to the spatial region of interest and acquisitions within 2020 (71 acquisitions). The nested \"for\" loops corresponding to the iteration over parcels, acquisition times, and pixels within the parcels indicate the computation-intensive character of the algorithm but also the potential for parallelization. Figure 1: Mean value from the normalized difference vegetation index (NDVI) pixel values that cover a single parcel. The NDVI values are extracted from a data cube that represents 71 Sentinel-2 acquisitions in 2020.