Python package to generate building shadow geometry
Project description
pybdshadow - building shadow analysis
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
Detail usage can be found in this example.
Shadow generated by Sun light
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)
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)
Installation
It is recommended to use Python 3.7, 3.8, 3.9
Using pypi
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pybdshadow-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c71fb2d857393bf8e29382347e24e6d137790c3344b5ebd31642a12cae3bd3f4 |
|
MD5 | 35e9f6d353417b4d8b7324c5ebef129a |
|
BLAKE2b-256 | 130e2a11a6ca719107d8adbe5b1e7d1e3c6eeb00ff3f872b6bed2bd18af15e44 |