Giter VIP home page Giter VIP logo

ni1o1 / pybdshadow Goto Github PK

View Code? Open in Web Editor NEW
41.0 2.0 4.0 23.07 MB

A python package for generating, analyzing and visualizing building shadows

Home Page: https://pybdshadow.readthedocs.io/en/latest/

License: BSD 3-Clause "New" or "Revised" License

Python 6.17% Jupyter Notebook 92.09% TeX 1.73%
python building-shadow sunlight gis building-outline-data geospatial-data urban-analysis

pybdshadow's Introduction

pybdshadow

1649074615552.png

Documentation Status Downloads codecov Tests Binder

Introduction

pybdshadow is a python package for generating, analyzing and visualizing building shadows from large scale building geographic data. pybdshadow support generate building shadows from both sun light and point light. pybdshadow provides an efficient and easy-to-use method to generate a new source of geospatial data with great application potential in urban study.

The latest stable release of the software can be installed via pip and full documentation can be found here.

Functionality

Currently, pybdshadow mainly provides the following methods:

  • Generating building shadow from sun light: With given location and time, the function in pybdshadow uses the properties of sun position obtained from suncalc-py and the building height to generate shadow geometry data.
  • Generating building shadow from point light: pybdshadow can generate the building shadow with given location and height of the point light, which can be potentially useful for visual area analysis in urban environment.
  • Analysis: pybdshadow integrated the analysing method based on the properties of sun movement to track the changing position of shadows within a fixed time interval. Based on the grid processing framework provided by TransBigData, pybdshadow is capable of calculating sunshine time on the ground and on the roof.
  • Visualization: Built-in visualization capabilities leverage the visualization package keplergl to interactively visualize building and shadow data in Jupyter notebooks with simple code.

The target audience of pybdshadow includes data science researchers and data engineers in the field of BIM, GIS, energy, environment, and urban computing.

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

Usage

Shadow generated by Sun light

Detail usage can be found in this example. pybdshadow is capable of generating shadows from building geographic data. The buildings are usually store in the data as the form of Polygon object with height information (usually Shapefile or GeoJSON file).

import pandas as pd
import geopandas as gpd
#Read building GeoJSON 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-py.

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)

Visualize buildings and shadows using matplotlib.

import matplotlib.pyplot as plt
fig = plt.figure(1, (12, 12))
ax = plt.subplot(111)
# plot buildings
buildings.plot(ax=ax)
# plot shadows
shadows['type'] += ' shadow'
shadows.plot(ax=ax, alpha=0.7,
             column='type',
             categorical=True,
             cmap='Set1_r',
             legend=True)
plt.show()

1651741110878.png

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 provides the functionality to analysis sunshine time on the roof and on the ground.

Result of shadow coverage on the roof:

1651645524782.png1651975815798.png

Result of sunshine time on the ground:

1651645530892.png1651975824187.png

Dependency

pybdshadow depends on the following packages

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.

pybdshadow's People

Contributors

console99 avatar imgbotapp avatar ni1o1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pybdshadow's Issues

Shadow on vertical walls

Hi,
As far as I understood from the documentation, pybdshadow is currently able to calculate shadows on the ground and on the roofs of buildings. I was just wondering, is it possible to calculate shadows also on vertical walls of buildings?
For my use case, I would not need a complete shadow calculation, I would just need to know if a specific wall surface is shadowed or not (a binary output). To simplify, it would be enough to know if a single point of the wall surface (e.g. the center) is shadowed.

An example of facade.py

Hello.
Can you please give an example of facade.py?
I would like to know about the simulation calculation of light intensity on a building facade.
Thank you very much.

TypeError: cannot astype a datetimelike from [datetime64[ns]] to [int32]

Describe the bug
i cloned this whole repository and installed it and run it , but faced this error in this part of the code

sunshine = pybdshadow.cal_sunshine(buildings_analysis,
                                   day='2022-01-01',
                                   roof=True,
                                   accuracy=1, #Set the accuracy  as number, it will generate grids as anlysis unit
                                   precision=900) .

Environment versions
python version : 3.11.0 64bit

Screenshots
image

Steps to reproduce error

  1. git clone https://github.com/ni1o1/pybdshadow.git (clone it into any directory).
  2. cd pybdshadow
  3. pip install pybdshadow
  4. cd Examples
  5. Now opened this Example1-building_shadow_analysis.ipynb file in jypter notebook and started run all command.

Desktop (please complete the following information):

  • OS: [ windows]
  • Browser [chrome]

Could you explain more on the data preparation pipeline?(How to get geojson file from OSM?) much appreciated!

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Shadow Simulation does not match with real situation

Hey!

I'm trying to calculate shadows on the roof of my building. To verify the model, I took various pictures through the day of the shadow on my roof, to compare them with the model output. In general it looks okay, but the shadows from the surrounding buildings are smaller than on my pictures.

To fix the issue, I have already tried various things:

  • checked all the coordinates again
  • checked the building heights (if I change the building height from the building that throws the shadow from 37 to 55 metres, the shadows from the simulation and my foto match during all times)
  • checked the time zone and conversion to UTC, summer and wintertime, and the time of sunrise and sundown
  • checked the calculated azimuth and altitude of the sun

Now I'm out of ideas, why the shadow in the simulation and my photo don't match. Do you have any idea what I could try to fix it?

Thank you!

parameter ground in bdshadow_sunlight function

Hi,
have a question regarding the bdshadow_sunlight function. I am not sure what the parameter "ground" means. The documentation says "height of the ground" and the default setting is zero. I interpreted the parameter as height above sea level of the area I am working with. But if I enter a ground height to the bdshadow_sunlight function that is equal or higher than the highest building I have in my data set, the following error occurs: "IndexError: too many indices for array: array is 1-dimensional, but 3 were indexed". So now I am a bit confused what the parameter "ground" means.

Shadows also before sunrise and after sunset

Hi,
thanks for this wonderful package, I'm really enjoying it!

I've noticed that with pybdshadow.bdshadow_sunlight shadow results are also provided before sunrise and after sunset for the local time,
it seems to me there should be an error thrown in this case, since the results are not meaningful (or simply a zero area shadow provided).

I imagine this type of check is already implemented for the calculations of light/shadow daily hours on a surface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.