Urban Energy Atlas
The atlas is designed as a white-label tool that can be deployed for any Spanish municipality. All processing code is modular and documented, with clear separation between the data pipeline (R), the spatial database (PostGIS), and the interactive front-end (Leaflet + Mapbox GL).
Spain's 2019 Royal Decree on collective self-consumption created a new framework allowing multiple consumers to share the output of a single photovoltaic installation. The Urban Energy Atlas was built to make this framework accessible to municipalities, energy cooperatives and urban planners without requiring specialist GIS knowledge.
The platform ingests open cadastral data (Catastro), LiDAR point clouds from the Spanish National Geographic Institute, and hourly PVPC electricity price series from Red Eléctrica to model every eligible rooftop in a given area.
LiDAR Rooftop Analysis
Raw LiDAR tiles are processed in R using the lidR package. A custom pipeline classifies ground and building returns, reconstructs rooftop polygons, and computes usable area, slope, and azimuth for each surface. Results are stored in a PostGIS database and served via a REST API to the front-end map.
The pipeline handles tiles across an entire municipality in parallel using future and furrr, reducing processing time from hours to minutes on standard hardware.
Community Grouping Algorithm
Assigning consumers to generators under Spanish regulation requires satisfying geographic proximity constraints (500 m radius), grid connection rules, and maximising collective self-consumption ratios simultaneously. A spatial grouping algorithm resolves these constraints using a combination of Voronoi partitioning and a genetic algorithm that optimises alpha coefficient distributions.
The algorithm is implemented in R and exposed as a Shiny module, allowing planners to adjust input parameters and preview community configurations interactively in real time.
Results
Across a pilot study covering 12,000 buildings in Valencia, the platform identified 3,400 eligible rooftops with a combined installable capacity of 48 MW. Modelled collective self-consumption ratios ranged from 62% to 89% depending on consumer-generator composition, with average household savings of €340/year at 2024 PVPC prices.
The methodology follows the technical specifications of IDAE's self-consumption guides and is designed to be extensible to other EU regulatory frameworks, including Italy's D.Lgs. 199/2021 (CACER) and France's autoconsommation collective (ACC) models.