/solar_berlin

Estimating the potential photovoltaic production of buildings (in Berlin)

Primary LanguagePython

The following people contributed equally to this repository (in alphabetical order):

A presentation of the project is available here.

This repository is forked on https://github.com/jjx3455/solar_berlin and https://github.com/cverst/solar_berlin to reflect the work of all contributors.

Estimating the potential photovoltaic production of Berlin rooftops

Prerequisites

Getting the original data

To download and convert the original data:

  • Create a subfolder "data" in the repository
  • If not using the pre-processed GeoTIFFs, download the original data:
    • Download map and vector files: cd conversion && sh download.sh
    • Convert from ecw to GeoTIFF: sh convert_rasters.sh
    • Clip the vector map to the same size as the raster tiles: python clip_shape.py

Extracting the data for the model

To extract the data into usable map/mask tiles and select a sample for the model:

  • Adjust parameters in select_data.py for desired sample size and tile size
  • Run python select_data.py
  • (This will take a while as it extracts all tiles of that size from the original data. The tiles are saved in the data/extracted folder so sampling again from the same tiles will be much faster.)

Running the current models

Two models can be run on the available data.

The first is a U-Net model with a pre-trained MobileNetV2 as the backbone for semantic segementation of rooftops (pixel-by-pixel prediction of roof/no-roof).

To run the unet model:

  • If not using the pre-extracted sample tiles:
    • modify the parameters in run_model.py to point at a different data selection folder
    • Run python run_model.py
    • Inspect results in logs The best model is unet/unet_resnet101v2.py

The second is a Detectron2 Mask R-CNN model with a pre-trained Resnet50 backbone for instance segmentation of roofs along with their PV category.

To run the model (Mask R-CNN):

  • Run the model:
    • modify the parameters in maskr/run_mask_r_cnn.py to point at a different data selection folder
    • Run python maskr/run_mask_r_cnn.py
  • Generate predictions:
    • modify the parameters in predict_from_mask_r_cnn.py
    • Run python predict_from_mask_r_cnn.py

Running Tests

Data for testing is managed with DVC (https://dvc.org/). To run the tests:

  • Download the test data dvc pull
  • Run python run_tests.py