/BuildingSimilarityIndex

Data gathering and processing of a similarity index based on the BAG & 3DBAG

Primary LanguagePython

3d project0002

Welcome to BuildingSimilarityIndex 👋

Version Documentation Maintenance

A Python library inspired by the 3d-building-metrics repo designed to create a pipeline for assessing building similarity. This library automatically collects data from the 3D-BAG and compares buildings using a turning function, metrics from the 3d-building-metrics repo, and general BAG data. It consists of three main modules: collection, processing, and similarity_calculation. These modules are integrated into a comprehensive module called BuildingsSimilarity.

  • The collection module downloads CityJSON files from the 3D-BAG based on a list of BAG IDs or a neighborhood ID.
  • The processing module merges the downloaded CityJSON files, calculates 2D/3D metrics, filters out unsuitable buildings (based on abnormal metric values), and applies a turning function. The output is a Pandas Dataframe containing the BAG IDs and the calculated metrics.
  • The similarity_calculation module preprocesses the data for similarity calculation by scaling, normalizing, handling N/A values and selecting relevant columns. The most basic form of similarity_calculation is to calculate the distance between two individual buildings. More advanced options are to calculate a (reference) distance matrix or to run ML-algorithms such as DBSCAN or K-Means

Prerequisites

  • python==3.11
  • An API key for the BAG. If you don't have one, you can apply for it free of charge

Usage

All modules can be used individually but are combined in BuildingSimilarity. Go to the demo directory for an example of how to use the module.

Installation

Clone the repo & install dependencies

git clone https://github.com/RetrofitEuropeGroup/FF_BuildingSimilarityIndex.git
cd FF_BuildingSimilarityIndex
pip install -r requirements.txt

Make sure to provide the BAG_API_KEY as an environmental variable. You can do this by setting an environmental variable directly or with a .env file in the root directory of the project. The code loads environmental values from the .env file. The .env file only needs one line:

BAG_API_KEY=your_api_key_here

Make sure to replace your_api_key_here with your actual BAG API key.

Potential errors

Note, it might be that you run into some errors. They are listed below with an solution (on Ubuntu 22.04):

ImportError: libXrender.so.1: cannot open shared object file: No such file or directory

apt-get install libxrender1

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

apt-get install libgl1

Show your support

Give a ⭐️ if this project helped you!