Package: pybdshadow
pybdshadowIntroductionpybdshadowis a python package for generating, analyzing and visualizing building shadows from large scale building geographic data.pybdshadowsupport generate building shadows from both sun light and point light.pybdshadowprovides 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 foundhere.FunctionalityCurrently,pybdshadowmainly provides the following methods:Generating building shadow from sun light: With given location and time, the function inpybdshadowuses the properties of sun position obtained fromsuncalc-pyand the building height to generate shadow geometry data.Generating building shadow from point light:pybdshadowcan 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:pybdshadowintegrated 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 byTransBigData,pybdshadowis capable of calculating sunshine time on the ground and on the roof.Visualization: Built-in visualization capabilities leverage the visualization packagekeplerglto interactively visualize building and shadow data in Jupyter notebooks with simple code.The target audience ofpybdshadowincludes data science researchers and data engineers in the field of BIM, GIS, energy, environment, and urban computing.InstallationIt is recommended to usePython 3.7, 3.8, 3.9Using pypipybdshadowcan be installed by usingpip install. Before installingpybdshadow, make sure that you have installed the availablegeopandas package. If you already have geopandas installed, run the following code directly from the command prompt to installpybdshadow:pipinstallpybdshadowUsageShadow generated by Sun lightDetail usage can be found inthis example.pybdshadowis capable of generating shadows from building geographic data.
The buildings are usually store in the data as the form of Polygon object withheightinformation (usually Shapefile or GeoJSON file).importpandasaspdimportgeopandasasgpd#Read building GeoJSON databuildings=gpd.read_file(r'data/bd_demo_2.json')Given a building GeoDataFrame and UTC datetime,pybdshadowcan calculate the building shadow based on the sun position obtained bysuncalc-py.importpybdshadow#Given UTC datetimedate=pd.to_datetime('2022-01-01 12:45:33.959797119')\.tz_localize('Asia/Shanghai')\.tz_convert('UTC')#Calculate building shadow for sun lightshadows=pybdshadow.bdshadow_sunlight(buildings,date)Visualize buildings and shadows using matplotlib.importmatplotlib.pyplotaspltfig=plt.figure(1,(12,12))ax=plt.subplot(111)# plot buildingsbuildings.plot(ax=ax)# plot shadowsshadows['type']+=' shadow'shadows.plot(ax=ax,alpha=0.7,column='type',categorical=True,cmap='Set1_r',legend=True)plt.show()pybdshadowalso provide visualization method supported by keplergl.# visualize buildings and shadowspybdshadow.show_bdshadow(buildings=buildings,shadows=shadows)Shadow generated by Point lightpybdshadowcan also calculate the building shadow generated by point light. Given coordinates and height of the point light:#Calculate building shadow for point lightshadows=pybdshadow.bdshadow_pointlight(buildings,139.713319,35.552040,200)#Visualize buildings and shadowspybdshadow.show_bdshadow(buildings=buildings,shadows=shadows)Shadow coverage analysispybdshadowprovides the functionality to analysis sunshine time on the roof and on the ground.Result of shadow coverage on the roof:Result of sunshine time on the ground:Dependencypybdshadowdepends on the following packagesnumpypandasshapelyrtreegeopandasmatplotlibsuncalckeplerglTransBigDataCitation informationCitation information can be found atCITATION.cff.Contributing to pybdshadowAll contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome. A detailed overview on how to contribute can be found in thecontributing guideon GitHub.