Predicting the Solar Potential of Rooftops using Image Segmentation and Structured Data

François Andrieux
Published in
8 min readApr 14, 2020


An aerial view of buildings’ roofs virtually covered with solar panels, in the south of France

How could we automatically estimate the amount of electricity that solar panels could generate on any building of a country, instantly? It would require to be able to massively compute the roofs topology and their weather condition as well as other key components such as:

  • the surface area available for the installation of solar modules;
  • the inclination and orientation, which are key factors in the production of electricity via photovoltaic solar panels;
  • detailed sunlight measurements, depending on the geolocation.

Although this information may be available at the scale of a city, it rarely exists at the scale of a country.

At namR, we used machine learning models trained on various data to predict the missing information and make this large scale estimation possible. We process open data (1) to train machine learning models (2) to recognize rooftops on aerial images (3) and predict their inclination (4), which enable us to estimate the maximum number of installable modules and their power generation (5).

Illustration of the five steps constituting our methodology
Illustration of the five steps constituting our methodology.

This article presents our methodology applied on the French territory. We also submitted these results to the Applied Machine Learning Days conference #AMLDays2020 at EPFL (Lausanne, Switzerland).

Why is this estimation important?

Before we go straight into the solution, we need to step back and look at the context. In our future world of 10 billion people, meeting the energy demand while limiting global warming is a major challenge. Yet, fossil fuels are still our main source of electricity and heat generation, accounting for 42% of the greenhouse gas emissions worldwide in 2016 [1]. To lower these numbers, energy efficiency and development of renewable energy are presented as the two main approaches [2].

Solar panels are one of the fastest-growing renewable energies, despite the presence of non-recyclable materials and a low average efficiency of 15% compared to 50% to 90% for hydropower or wind power [3]. But their operation and maintenance costs are low, and modules can be installed as well on the ground as on top of a roof: useful for cities, where space is limited resource. Estimating the production of solar panels on a large scale is therefore a key challenge to accelerate this transition.

Combining open data and AI

At namR, we are building a digital representation of the world to perform ecological, economical and digital transformations. As a data producer, we aggregate, clean and re-organize data from various sources that can help to solve real world problems at a large scale. To solve this problem, we decided to use computer vision to identify the roofs and structured data to compute or predict their characteristics.

In France, aerial images are provided by the National Geographic Institute (IGN) with a resolution of 20 cm per pixel and covering the entire territory. We sought to achieve a segmentation of each roof section with different inclinations and orientations and therefore a different solar potential.

To train this model, we used 3D models of buildings and roofs of some French cities (Bordeaux, Brest, Montpellier and Strasbourg), taking care to clean and aggregate adjoining geometries between them when necessary.

The image depicts two group of polygons in a 3D space representing roof slopes being merged together
Illustration of preprocessing algorithm. (1) cluster touching geometries (2) cluster by normal vector (3) merge each sub-cluster to create the definitive geometries.

This Open Data integration has allowed us to build a solid dataset of more than 1 million roof slopes corresponding to various aerial images. We therefore rasterized the 2D-projected geometries and trained a deep convolutional neural network to predict 3 classes: “background”, “slope” and “ridge”. The choice of the model fell on the U-Net [4] because of its faster and more stable inference compared to our previous shot with Mask-RCNN [5].

Four examples of an aerial image and its achieved segmentation of the roof slopes.
Illustration of the achieved roof slope segmentation.
‘slope’ is depicted in blue, ‘ridge’ in yellow and ‘background’ is everything else.

The model correctly classified 77.27% of the slope and ridge pixels, but the raw output however required post-processing to fix incorrect shapes and facilitate further computation. The aim is then twofold:

  • to correct the imperfections of the segmentation (e.g. small orphan geometries);
  • to maximize the surface area of the roof areas by regaining the space classified as “ridge”.
Four images at the top and five at the bottom represent the post-processing steps to improve roof slopes.
Two illustrations of the post-processing steps to clean up the CV segmentation.

We regularized the roof slopes using mathematical morphology techniques and geometric operations using the (awesome) spatial database extension PostGIS. Eventually, this post-processing enabled us to reclaim 23% of the available surface (median value).

However, obstructing objects must also be taken into account to determine the available roof area. Using the same methodology, we applied ourselves to segment roof objects such as chimneys, windows, and others objects that can prevent the installation of solar modules.

The image has two parts representing two examples of aerial images with object segmentation on rooftops in red and blue.
Illustrations of the achieved roof object segmentation.
The model has a tendency for over detection, which may lower the available roof area.

Although the first results are satisfying, the model has a tendency to overpredict objects where it should not because of the difficulty of distinguishing objects in aerial views, even for humans. We are still working on it to improve the scores.

Estimating a roof azimuth and pitch

Having the proper roof surface boundaries enable us to geometrically compute the azimuth α (orientation). However, it is complicated to extract depth information from aerial images such as the pitch θ (inclination) of a slope.

We’ve chosen the strategy of geometrically compute inclination values from the 3D training dataset and use them as labels to train a Random Forest regressor [6] to output the pitch. The features we used to describe the roof and feed the model are derived from nam.R’s original Digital Twin database that contains building-centered valuable information such as the footprint area, perimeter, number of adjoining buildings, roof material and types, floor number, etc. produced by aggregating open data sources and machine learning techniques.

The image depicts an illustration, a list of features for a Random Forest model and the histogram of the predicted values.
Illustration of the pitch and azimuth of a simple roof.
We used a random forest to predict the pitch and geometrically computed the azimuth.

Because of the high variability of the roof types and variance of the pitch inside the same roof, the model overpredicts 20°, the average pitch of the labels used to train it, which could be improved by considering more features extracted from the roof geometry.

Maximizing the number of solar panels

Up to this point, we had the roof slope boundaries, their surface, orientation and inclination as well as the potential obstructing objects. To estimate the maximum number of solar panels that could fit into the roof, we simply packed as many solar panels along the main axis of the geometry. Then we removed panels intersecting objects or roof boundaries.

The left omage depicts the packing algorithm and the right image an example.
Illustration of the packing algorithm: (1) get the roof slope main axis (2) greedily place panels (3) remove panels intersecting the objects or boundaries (4) compute the covered area.
The image is an example with two roof objects.

The result is assumed to be near optimal by greedily packing solar panels starting from a range of offsets, producing different placements and intersections with objects and roof boundaries. This time, we used Python and the geometric library Shapely to compute geometric intersections iteratively.

Estimating the solar potential

The solar potential of a location can be defined as the amount of solar energy this location can receive over a year. The solar energy (or solar power) is a form of energy such as heat or electricity that can be transformed using various technologies including solar panels.

However, all solar panels does not produce the same solar power. It depends on the pitch, azimuth, total irradiation (global horizontal irradiation and direct normal irradiation) and geolocation. It is defined as the PVoutput (kWh/kWp): the specific photovoltaic power output of the installation, an average of the yearly production normalized to 1 kWp of installed capacity. Some resources such as PVGIS and Global Solar Atlas are useful to computing it, and so far we decided to Global Solar Atlas’ open data.

For our usage, we defined the solar potential as being the amount of electricity that we could produce in one year with the best configuration of solar panels, such as:

with Npanels being the maximum number of solar panels on the slope and Pn (kW) the nominal capacity of a solar panel.


Without real values to compare ourselves to, it is complicated to precisely score our results. However, the calculation of the PVoutput using the position of our roofs, azimuth and pitch gave us results that are consistent with the geographical position of France:

  • South-facing slopes maximize the PVoutput compared to north-facing slopes.
  • West facing slopes have a PVoutput equivalent to East facing slopes.

However, this does not mean that a south-facing slope will necessarily produce more electricity than another and depends on the number of solar panels. And generally speaking, roofs of large buildings maximize this production, as shown in the figure below:

An aerial view with rooftops coloured according to their solar potential
Illustration: the annual solar potential (kWh/year) on a sample area in the south of France.

By the time these algorithms ran, we estimated the solar potential of 1.3 million roof slopes accounting for more than 538,000 buildings on a test area in France. Our work today is focused on estimating it on a larger scope and eventually on the whole country.


We are proud of this project, because it demonstrates that it is possible to massively estimate the solar potential from various sources of open data. It also shows that it is possible to actually calculate the number of solar panels that can be installed and not just a broad estimate of electricity production.

For us, the major challenge was to achieve a good segmentation of the rooftops, crucial for the overall quality. Currently, we are working on improving two points: the objects’ segmentation that needs more training data, and pitch prediction that might require more information on the geometrical context of the roof.

At namR, our goal is to help organizations leverage geolocated data and AI in their projects. As the solar energy is part of our larger offer on energy and green retrofit, we are thrilled to continue this project by scaling it to other parts of the world to help ecological transition and build sustainable cities.


[1] IEA — International Energy Agency, “CO2 Emissions Statistics” (2018).
[2] D. Rolnick et al., “Tackling Climate Change with Machine Learning” (2019).
[3] IRENA — International Renewable Energy Agency, “Renewable Power Generation Costs in 2017” (2018).
[4] O. Renneberger, P. Fischer, T. Brox, “U-Net: Convolutional Networks for Biomedical Image Segmentation” (2015).
[5] K. He, G. Gkioxari, P. Dollar and R. Girshick, “Mask R-CNN” (2017).
[6] L. Breiman, “Random Forests” (2001).

If you liked this article, you may also be interested in our geospatial intelligence blog, or you can find me on twitter @Spriteware.



François Andrieux

Geo Data Scientist at @namr_france, @Spriteware on Twitter. I create Machine Learning algorithms and Geospatial Analysis for cities and environment