Skip to main content

Python package to generate building shadow geometry

Project description

pybdshadow - building shadow analysis

1649074615552.png

Documentation Status Downloads codecov Tests

Introduction

pybdshadow is a python package to analyze building shadow. The latest stable release of the software can be installed via pip and full documentation can be found here.

Example

Shadow generated by Sun light

Detail usage can be found in this example. pybdshadow is capable of generating shadows from building outline data. Building outline data can be obtain by Python package OSMnx from OpenStreetMap. The buildings are usually store in the data as the form of Polygon object with height column.

import pandas as pd
import geopandas as gpd
#Read building data
buildings = gpd.read_file(r'data/bd_demo_2.json')

Given a building GeoDataFrame and UTC datetime, pybdshadow can calculate the building shadow based on the sun position obtained by suncalc

import pybdshadow
#Given UTC datetime
date = pd.to_datetime('2022-01-01 12:45:33.959797119')\
    .tz_localize('Asia/Shanghai')\
    .tz_convert('UTC')
#Calculate building shadow for sun light
shadows = pybdshadow.bdshadow_sunlight(buildings,date)

pybdshadow also provide visualization method supported by keplergl.

# visualize buildings and shadows
pybdshadow.show_bdshadow(buildings = buildings,shadows = shadows)

1649161376291.png

Shadow generated by Point light

pybdshadow can also calculate the building shadow generated by point light. Given coordinates and height of the point light:

#Calculate building shadow for point light
shadows = pybdshadow.bdshadow_pointlight(buildings,139.713319,35.552040,200)
#Visualize buildings and shadows
pybdshadow.show_bdshadow(buildings = buildings,shadows = shadows)

1649405838683.png

Shadow coverage analysis

pybdshadow also have the functionality to calculate the shadow on the roof.

1651506285290.png

Base on this functionality, pybdshadow can also analysis shadow coverage on the roof and on the ground. Detail usage can be found in this example.

1651490411329.png

Result of shadow coverage on the roof.

1651490416315.png

Result of shadow coverage on the ground.

Installation

It is recommended to use Python 3.7, 3.8, 3.9

Using pypi PyPI version

pybdshadow can be installed by using pip install. Before installing pybdshadow, make sure that you have installed the available geopandas package. If you already have geopandas installed, run the following code directly from the command prompt to install pybdshadow:

pip install pybdshadow

Dependency

pybdshadow depends on the following packages

  • numpy
  • pandas
  • shapely
  • rtree
  • geopandas
  • matplotlib
  • suncalc
  • keplergl

Citation information

Citation information can be found at CITATION.cff.

Contributing to pybdshadow GitHub contributors GitHub commit activity

All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome. A detailed overview on how to contribute can be found in the contributing guide on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybdshadow-0.3.1.tar.gz (15.1 kB view hashes)

Uploaded Source

Built Distribution

pybdshadow-0.3.1-py3-none-any.whl (21.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page