Unlocking Solar Potential: Optimal Locations for Solar Panel Placement

Benjamin Goehry
TotalEnergies Digital Factory
6 min readOct 9, 2023
Picture from tawatchai07 on Freepik

TotalEnergies’ ambition is to achieve carbon neutrality by 2050, together with society. With this goal in mind, TotalEnergies is committed to generating 100GW of low-carbon electricity worldwide by 2030. This entails accelerating the deployment of photovoltaic solar power solutions on rooftops, parking lots, and other underutilized lands of the Company’s clients.

In the following, we will see how to leverage the business knowledge as well as the data quantity, to automate, and hence help, the expansion of solar energy. The question we want to address is “How can buildings be ranked for the placement of photovoltaic power plants?”. The answer to this question is crucial. We cannot lose time on a project that will not generate any electricity production. We need to proactively identify both the most favorable and the least favorable opportunities that align with the Company’s goals.

Usually the first problem that arises is how to get the buildings’ data. In this use case, we may think of many data sources: open data sources, detecting the buildings via computer vision automatically, input of the users via a list of coordinates, and many more. In the context below, the only essential information about the data is that a building can be represented as a georeferenced polygon, with each vertex having a specific location (such as latitude and longitude). This also means that everything that follows can be generalized to other structures than buildings.

Solar Panel Placement Criteria

Next, we need a bit of business knowledge to know what a “good” building is. This is highly dependent on the kind of operational mode of the photovoltaic power plant. Nevertheless, there are some universally applicable criteria, and we will examine three such factors.

The surface area of the roof plays a significant role: the larger it is, the more advantageous. A greater surface area translates to higher electricity production and, relatively, optimised capital and operational expenses. Moreover, regions with higher solar irradiance tend to experience increased electricity output and improved panel energy yield. This is why solar panels are more prevalent in the southern parts of Europe compared to the northern regions. The final criterion under consideration is the rectangularity of the building. Solar panels are commonly designed in rectangular shapes, making them most compatible with similarly shaped surfaces. Thus, the closer a building’s shape is to a rectangle, the greater its potential for accommodating panels across its surface.

In this article, we will focus on how to store georeferenced data. Since we are handling geometries, a special kind of database is required. After that, we will explore how to utilize this database to work with the geometries and define the criteria demonstrated earlier. Finally, we will demonstrate how to leverage these features to rank the buildings.

PostGIS

PostgreSQL stands as one of the leading open-source object-relational database systems, utilizing and expanding upon the SQL language. PostGIS further enhances these capabilities, allowing for the storage, indexing, and querying of geographic data — precisely tailored to our requirements. It seamlessly complements standard SQL queries, maintaining a harmonious semantic alignment, while also excelling in terms of performance.

When it comes to installation, the first step entails verifying the presence of PostgreSQL, followed by the installation of PostGIS. Subsequently, we proceed to create the database in which we intend to store our geospatial data.

CREATE DATABASE postgisdb;

Once connected to the newly created database, our next action is to add the extension and generate a table designed for storing polygons.

CREATE EXTENSION postgis;
CREATE TABLE geometries (name varchar(255), geom geometry);

Plainly, when inserting polygons into this table, the process looks very much like standard SQL, demonstrating that, apart from the geometric terminology, the procedures remain consistent.

INSERT INTO geometries VALUES
('Building 1', 'POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))'),
('Building 2', 'POLYGON((0 0, 10 0, 10 10, 0 10, 0 0),(1 1, 1 2, 2 2, 2 1, 1 1))'),
('Building 3', 'POLYGON((0 0, 2 1, 0 1, 0 0))'),
('Building 4', 'POLYGON((0 0, 5 0, 5 2, 3 2, 2 2, 2 1, 0 1, 0 0))');

We can easily display the values stored in the table. The primary difference from conventional SQL lies in the necessity of specifying how to present geometries.

SELECT name, ST_AsText(geom) FROM geometries;
Output from the previous SQL query

Let’s incorporate the first criterion — surface area — into the table. Notably, one of PostGIS’s strengths is its comprehensive implementation and optimization of fundamental “geometrical” operations. This eliminates the need for additional programming languages at this stage.

ALTER TABLE geometries ADD COLUMN surface double precision;
UPDATE geometries SET surface=ST_Area(geom);

Another criterion for computation is the rectangularity of a polygon. This involves calculating the area ratio between the polygon and its minimum bounding rectangle.

ALTER TABLE geometries ADD COLUMN rectangularity double precision;
UPDATE geometries SET rectangularity=ST_Area(geom)/ST_Area(ST_OrientedEnvelope(geom));
Building 4 in blue with its corresponding minimum bounding rectangle highlighted in gray.

In our current context, the remaining task involves adding solar irradiance data corresponding to the buildings’ roofs. (This task is left to the reader)

Table after adding the criteria

Scoring and ranking

Now that we have defined all our criteria, it’s time to rank the rooftops. However, our use case presents a challenge: we lack predefined labels for what constitutes a “good” rooftop, and there are no established “truth” rankings. So, how do we proceed?

Here enters TOPSIS, a multi-criteria decision analysis method. The concept involves assigning weights to each criterion, creating the “worst” and “best” solutions based on these weights, evaluating the similarity to the worst-case scenario, and there you have it — an assigned score. The ranking is then determined by arranging these scores in order. The brilliance of this method lies in its independence from labeled data; the business can easily adjust weights to explore different scenarios.

Shifting our attention to the coding aspect, we employ Scikit-Criteria. To use the TOPSIS function, we provide a decision matrix where criterion weights and whether to maximize or minimize are defined. In our scenario, let’s assume the following order of criterion importance: irradiance > surface > rectangularity.

DECISION_MATRIX: Dict = {
"irradiance": {"weight": 0.9, "objective": max},
"surface": {"weight": 0.7, "objective": max},
"rectangularity": {"weight": 0.2, "objective": max},
}

The code snippet below takes the decision matrix and the relevant data as inputs to generate scores and rankings.

def get_rank_from_features_and_decision_matrix(
decision_matrix: Dict, df: gpd.GeoDataFrame,
) -> gpd.GeoDataFrame:
dm = skc.mkdm(matrix=df[list(decision_matrix.keys())].values,
objectives=[v['objective'] for v in decision_matrix.values()],
criteria=list(decision_matrix.keys()),
weights=[v['weight'] for v in decision_matrix.values()],
alternatives=df.index)

pipe = mkpipe(
invert_objectives.NegateMinimize(),
scalers.MinMaxScaler(target="matrix"),
scalers.SumScaler(target="weights"),
TOPSIS()
)

rank = pipe.evaluate(dm)
df["rank"] = rank.values
df["score"] = rank.e_.similarity
return df

By appending the new “score” and “rank” columns to our table, we unveil the much-awaited results.

Conclusion

In summary, this article highlights an approach for ranking prime solar panel locations. Notably, a significant advantage of this method is its ability to provide recommendations without relying on labeled data. Unlike traditional approaches which often demand extensive historical information, TOPSIS leverages both the available data and the business knowledge to make well-informed decisions. Through PostGIS, georeferenced data finds its optimal storage and querying solution, further enhancing the efficiency of the approach.

Armed with the PostGIS-TOPSIS combo, we’re empowered to shape a greener, more sustainable future.

--

--