voxcity 0.5.10__py3-none-any.whl → 0.5.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of voxcity might be problematic. Click here for more details.
- voxcity/generator.py +102 -1
- {voxcity-0.5.10.dist-info → voxcity-0.5.11.dist-info}/METADATA +1 -1
- {voxcity-0.5.10.dist-info → voxcity-0.5.11.dist-info}/RECORD +7 -7
- {voxcity-0.5.10.dist-info → voxcity-0.5.11.dist-info}/WHEEL +0 -0
- {voxcity-0.5.10.dist-info → voxcity-0.5.11.dist-info}/licenses/AUTHORS.rst +0 -0
- {voxcity-0.5.10.dist-info → voxcity-0.5.11.dist-info}/licenses/LICENSE +0 -0
- {voxcity-0.5.10.dist-info → voxcity-0.5.11.dist-info}/top_level.txt +0 -0
voxcity/generator.py
CHANGED
|
@@ -689,6 +689,14 @@ def get_voxcity(rectangle_vertices, building_source, land_cover_source, canopy_h
|
|
|
689
689
|
voxcity_grid_vis[-1, -1, -1] = -99 # Add marker to fix camera location and angle of view
|
|
690
690
|
visualize_3d_voxel(voxcity_grid_vis, voxel_size=meshsize, save_path=kwargs["voxelvis_img_save_path"])
|
|
691
691
|
|
|
692
|
+
# Save all data if a save path is provided
|
|
693
|
+
save_voxcity = kwargs.get("save_voxctiy_data", True)
|
|
694
|
+
if save_voxcity:
|
|
695
|
+
save_path = kwargs.get("save_data_path", f"{output_dir}/voxcity_data.pkl")
|
|
696
|
+
save_voxcity_data(save_path, voxcity_grid, building_height_grid, building_min_height_grid,
|
|
697
|
+
building_id_grid, canopy_height_grid, land_cover_grid, dem_grid,
|
|
698
|
+
building_gdf, meshsize, rectangle_vertices)
|
|
699
|
+
|
|
692
700
|
return voxcity_grid, building_height_grid, building_min_height_grid, building_id_grid, canopy_height_grid, land_cover_grid, dem_grid, building_gdf
|
|
693
701
|
|
|
694
702
|
def get_voxcity_CityGML(rectangle_vertices, land_cover_source, canopy_height_source, meshsize, url_citygml=None, citygml_path=None, **kwargs):
|
|
@@ -817,6 +825,14 @@ def get_voxcity_CityGML(rectangle_vertices, land_cover_source, canopy_height_sou
|
|
|
817
825
|
# Generate 3D voxel grid
|
|
818
826
|
voxcity_grid = create_3d_voxel(building_height_grid, building_min_height_grid, building_id_grid, land_cover_grid, dem_grid, canopy_height_grid, meshsize, land_cover_source)
|
|
819
827
|
|
|
828
|
+
# Save all data if a save path is provided
|
|
829
|
+
save_voxcity = kwargs.get("save_voxctiy_data", True)
|
|
830
|
+
if save_voxcity:
|
|
831
|
+
save_path = kwargs.get("save_data_path", f"{output_dir}/voxcity_data.pkl")
|
|
832
|
+
save_voxcity_data(save_path, voxcity_grid, building_height_grid, building_min_height_grid,
|
|
833
|
+
building_id_grid, canopy_height_grid, land_cover_grid, dem_grid,
|
|
834
|
+
building_gdf, meshsize, rectangle_vertices)
|
|
835
|
+
|
|
820
836
|
return voxcity_grid, building_height_grid, building_min_height_grid, building_id_grid, canopy_height_grid, land_cover_grid, dem_grid, filtered_buildings
|
|
821
837
|
|
|
822
838
|
def replace_nan_in_nested(arr, replace_value=10.0):
|
|
@@ -844,4 +860,89 @@ def replace_nan_in_nested(arr, replace_value=10.0):
|
|
|
844
860
|
if isinstance(arr[i][j][k][l], float) and np.isnan(arr[i][j][k][l]):
|
|
845
861
|
arr[i][j][k][l] = replace_value
|
|
846
862
|
|
|
847
|
-
return np.array(arr, dtype=object)
|
|
863
|
+
return np.array(arr, dtype=object)
|
|
864
|
+
|
|
865
|
+
def save_voxcity_data(output_path, voxcity_grid, building_height_grid, building_min_height_grid,
|
|
866
|
+
building_id_grid, canopy_height_grid, land_cover_grid, dem_grid,
|
|
867
|
+
building_gdf, meshsize, rectangle_vertices):
|
|
868
|
+
"""Save voxcity data to a file for later loading.
|
|
869
|
+
|
|
870
|
+
Args:
|
|
871
|
+
output_path: Path to save the data file
|
|
872
|
+
voxcity_grid: 3D voxel grid of the complete city model
|
|
873
|
+
building_height_grid: 2D grid of building heights
|
|
874
|
+
building_min_height_grid: 2D grid of minimum building heights
|
|
875
|
+
building_id_grid: 2D grid of building IDs
|
|
876
|
+
canopy_height_grid: 2D grid of tree canopy heights
|
|
877
|
+
land_cover_grid: 2D grid of land cover classifications
|
|
878
|
+
dem_grid: 2D grid of ground elevation
|
|
879
|
+
building_gdf: GeoDataFrame of building footprints and metadata
|
|
880
|
+
meshsize: Size of each grid cell in meters
|
|
881
|
+
rectangle_vertices: List of coordinates defining the area of interest
|
|
882
|
+
"""
|
|
883
|
+
import pickle
|
|
884
|
+
import os
|
|
885
|
+
|
|
886
|
+
# Create directory if it doesn't exist
|
|
887
|
+
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
|
888
|
+
|
|
889
|
+
# Create a dictionary with all the data
|
|
890
|
+
data_dict = {
|
|
891
|
+
'voxcity_grid': voxcity_grid,
|
|
892
|
+
'building_height_grid': building_height_grid,
|
|
893
|
+
'building_min_height_grid': building_min_height_grid,
|
|
894
|
+
'building_id_grid': building_id_grid,
|
|
895
|
+
'canopy_height_grid': canopy_height_grid,
|
|
896
|
+
'land_cover_grid': land_cover_grid,
|
|
897
|
+
'dem_grid': dem_grid,
|
|
898
|
+
'building_gdf': building_gdf,
|
|
899
|
+
'meshsize': meshsize,
|
|
900
|
+
'rectangle_vertices': rectangle_vertices
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
# Save the data to a file using pickle
|
|
904
|
+
with open(output_path, 'wb') as f:
|
|
905
|
+
pickle.dump(data_dict, f)
|
|
906
|
+
|
|
907
|
+
print(f"Voxcity data saved to {output_path}")
|
|
908
|
+
|
|
909
|
+
def load_voxcity_data(input_path):
|
|
910
|
+
"""Load voxcity data from a saved file.
|
|
911
|
+
|
|
912
|
+
Args:
|
|
913
|
+
input_path: Path to the saved data file
|
|
914
|
+
|
|
915
|
+
Returns:
|
|
916
|
+
tuple: All the voxcity data components including:
|
|
917
|
+
- voxcity_grid: 3D voxel grid of the complete city model
|
|
918
|
+
- building_height_grid: 2D grid of building heights
|
|
919
|
+
- building_min_height_grid: 2D grid of minimum building heights
|
|
920
|
+
- building_id_grid: 2D grid of building IDs
|
|
921
|
+
- canopy_height_grid: 2D grid of tree canopy heights
|
|
922
|
+
- land_cover_grid: 2D grid of land cover classifications
|
|
923
|
+
- dem_grid: 2D grid of ground elevation
|
|
924
|
+
- building_gdf: GeoDataFrame of building footprints and metadata
|
|
925
|
+
- meshsize: Size of each grid cell in meters
|
|
926
|
+
- rectangle_vertices: List of coordinates defining the area of interest
|
|
927
|
+
"""
|
|
928
|
+
import pickle
|
|
929
|
+
|
|
930
|
+
# Load the data from the file
|
|
931
|
+
with open(input_path, 'rb') as f:
|
|
932
|
+
data_dict = pickle.load(f)
|
|
933
|
+
|
|
934
|
+
print(f"Voxcity data loaded from {input_path}")
|
|
935
|
+
|
|
936
|
+
# Return all components as a tuple
|
|
937
|
+
return (
|
|
938
|
+
data_dict['voxcity_grid'],
|
|
939
|
+
data_dict['building_height_grid'],
|
|
940
|
+
data_dict['building_min_height_grid'],
|
|
941
|
+
data_dict['building_id_grid'],
|
|
942
|
+
data_dict['canopy_height_grid'],
|
|
943
|
+
data_dict['land_cover_grid'],
|
|
944
|
+
data_dict['dem_grid'],
|
|
945
|
+
data_dict['building_gdf'],
|
|
946
|
+
data_dict['meshsize'],
|
|
947
|
+
data_dict['rectangle_vertices']
|
|
948
|
+
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: voxcity
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.11
|
|
4
4
|
Summary: voxcity is an easy and one-stop tool to output 3d city models for microclimate simulation by integrating multiple geospatial open-data
|
|
5
5
|
Author-email: Kunihiko Fujiwara <kunihiko@nus.edu.sg>
|
|
6
6
|
Maintainer-email: Kunihiko Fujiwara <kunihiko@nus.edu.sg>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
voxcity/__init__.py,sha256=el9v3gfybHOF_GUYPeSOqN0-vCrTW0eU1mcvi0sEfeU,252
|
|
2
|
-
voxcity/generator.py,sha256=
|
|
2
|
+
voxcity/generator.py,sha256=qWe2LJsbY2_IYUuI99ZJ5_rRNJ8IQrEIdxND7azYd-M,47045
|
|
3
3
|
voxcity/downloader/__init__.py,sha256=OgGcGxOXF4tjcEL6DhOnt13DYPTvOigUelp5xIpTqM0,171
|
|
4
4
|
voxcity/downloader/citygml.py,sha256=R3DvsYJz_S5OPkeA71eEI2U7fBDLcpqdludV6gO1ihw,30305
|
|
5
5
|
voxcity/downloader/eubucco.py,sha256=XCkkdEPNuWdrnuxzL80Ext37WsgiCiZGueb-aQV5rvI,14476
|
|
@@ -30,9 +30,9 @@ voxcity/utils/lc.py,sha256=RwPd-VY3POV3gTrBhM7TubgGb9MCd3nVah_G8iUEF7k,11562
|
|
|
30
30
|
voxcity/utils/material.py,sha256=Vt3IID5Ft54HNJcEC4zi31BCPqi_687X3CSp7rXaRVY,5907
|
|
31
31
|
voxcity/utils/visualization.py,sha256=jsKfUoRRW0yRCmJ03I7ESK1Tic_Xk1tcliw-8syr3Y0,87228
|
|
32
32
|
voxcity/utils/weather.py,sha256=CFPtoqRTajwMRswswDChwQ3BW1cGsnA3orgWHgz7Ehg,26304
|
|
33
|
-
voxcity-0.5.
|
|
34
|
-
voxcity-0.5.
|
|
35
|
-
voxcity-0.5.
|
|
36
|
-
voxcity-0.5.
|
|
37
|
-
voxcity-0.5.
|
|
38
|
-
voxcity-0.5.
|
|
33
|
+
voxcity-0.5.11.dist-info/licenses/AUTHORS.rst,sha256=m82vkI5QokEGdcHof2OxK39lf81w1P58kG9ZNNAKS9U,175
|
|
34
|
+
voxcity-0.5.11.dist-info/licenses/LICENSE,sha256=s_jE1Df1nTPL4A_5GCGic5Zwex0CVaPKcAmSilxJPPE,1089
|
|
35
|
+
voxcity-0.5.11.dist-info/METADATA,sha256=hK1HErMdMRO_166kD7r3ZeGGT9pZq6Ok54PbcwpCYJA,25885
|
|
36
|
+
voxcity-0.5.11.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
|
37
|
+
voxcity-0.5.11.dist-info/top_level.txt,sha256=00b2U-LKfDllt6RL1R33MXie5MvxzUFye0NGD96t_8I,8
|
|
38
|
+
voxcity-0.5.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|