voxcity 0.3.24__py3-none-any.whl → 0.3.27__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 CHANGED
@@ -82,7 +82,8 @@ def get_land_cover_grid(rectangle_vertices, meshsize, source, output_dir, **kwar
82
82
  print(f"Data source: {source}")
83
83
 
84
84
  # Initialize Earth Engine for accessing satellite data
85
- initialize_earth_engine()
85
+ if source is not "OpenStreetMap":
86
+ initialize_earth_engine()
86
87
 
87
88
  # Create output directory if it doesn't exist
88
89
  os.makedirs(output_dir, exist_ok=True)
@@ -157,7 +158,8 @@ def get_building_height_grid(rectangle_vertices, meshsize, source, output_dir, *
157
158
  """
158
159
 
159
160
  # Initialize Earth Engine for accessing satellite data
160
- initialize_earth_engine()
161
+ if source is not "OpenStreetMap":
162
+ initialize_earth_engine()
161
163
 
162
164
  print("Creating Building Height grid\n ")
163
165
  print(f"Data source: {source}")
@@ -320,7 +322,7 @@ def get_dem_grid(rectangle_vertices, meshsize, source, output_dir, **kwargs):
320
322
  image = get_dem_image(roi_buffered, source)
321
323
 
322
324
  # Save DEM data with appropriate resolution based on source
323
- if source in ["England 1m DTM", 'DEM France 1m', 'DEM France 5m', 'AUSTRALIA 5M DEM']:
325
+ if source in ["England 1m DTM", 'DEM France 1m', 'DEM France 5m', 'AUSTRALIA 5M DEM', 'Netherlands 0.5m DTM']:
324
326
  save_geotiff(image, geotiff_path, scale=meshsize, region=roi_buffered, crs='EPSG:4326')
325
327
  elif source == 'USGS 3DEP 1m':
326
328
  scale = max(meshsize, 1.25)
@@ -569,7 +571,18 @@ def get_voxcity(rectangle_vertices, building_source, land_cover_source, canopy_h
569
571
  building_gdf.to_file(save_path, driver='GPKG')
570
572
 
571
573
  # Get canopy height data
572
- canopy_height_grid = get_canopy_height_grid(rectangle_vertices, meshsize, canopy_height_source, output_dir, **kwargs)
574
+ if canopy_height_source == "Static":
575
+ # Create canopy height grid with same shape as land cover grid
576
+ canopy_height_grid = np.zeros_like(land_cover_grid, dtype=float)
577
+
578
+ # Set default static height for trees (20 meters is a typical average tree height)
579
+ static_tree_height = kwargs.get("static_tree_height", 10.0)
580
+ tree_mask = (land_cover_grid == 4)
581
+
582
+ # Set static height for tree cells
583
+ canopy_height_grid[tree_mask] = static_tree_height
584
+ else:
585
+ canopy_height_grid = get_canopy_height_grid(rectangle_vertices, meshsize, canopy_height_source, output_dir, **kwargs)
573
586
 
574
587
  # Handle DEM - either flat or from source
575
588
  if dem_source == "Flat":
@@ -1109,6 +1109,116 @@ def visualize_voxcity_multi_view(voxel_array, meshsize, **kwargs):
1109
1109
  plt.show()
1110
1110
  plt.close()
1111
1111
 
1112
+ def visualize_voxcity_multi_view_with_multiple_sim_grids(voxel_array, meshsize, sim_configs, **kwargs):
1113
+ """
1114
+ Create multiple views of the voxel city data with multiple simulation grids.
1115
+
1116
+ Args:
1117
+ voxel_array: 3D numpy array containing voxel data
1118
+ meshsize: Size of each voxel/cell
1119
+ sim_configs: List of dictionaries, each containing configuration for a simulation grid:
1120
+ {
1121
+ 'sim_grid': 2D numpy array of simulation values,
1122
+ 'z_offset': height offset in meters (default: 1.5),
1123
+ 'cmap_name': colormap name (default: 'viridis'),
1124
+ 'vmin': minimum value for colormap (optional),
1125
+ 'vmax': maximum value for colormap (optional),
1126
+ 'label': label for the colorbar (optional)
1127
+ }
1128
+ **kwargs: Additional arguments including:
1129
+ - vox_dict: Dictionary mapping voxel values to colors
1130
+ - output_directory: Directory to save output images
1131
+ - output_file_name: Base filename for exports
1132
+ - dem_grid: DEM grid for height information
1133
+ - projection_type: 'perspective' or 'orthographic'
1134
+ - distance_factor: Factor to adjust camera distance
1135
+ """
1136
+ os.system('Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &')
1137
+ os.environ['DISPLAY'] = ':99'
1138
+
1139
+ # Configure PyVista settings
1140
+ pv.set_plot_theme('document')
1141
+ pv.global_theme.background = 'white'
1142
+ pv.global_theme.window_size = [1024, 768]
1143
+ pv.global_theme.jupyter_backend = 'static'
1144
+
1145
+ # Parse general kwargs
1146
+ vox_dict = kwargs.get("vox_dict", get_default_voxel_color_map())
1147
+ output_directory = kwargs.get("output_directory", 'output')
1148
+ base_filename = kwargs.get("output_file_name", None)
1149
+ dem_grid_ori = kwargs.get("dem_grid", None)
1150
+ projection_type = kwargs.get("projection_type", "perspective")
1151
+ distance_factor = kwargs.get("distance_factor", 1.0)
1152
+
1153
+ if dem_grid_ori is not None:
1154
+ dem_grid = dem_grid_ori - np.min(dem_grid_ori)
1155
+
1156
+ # Create meshes
1157
+ print("Creating voxel meshes...")
1158
+ meshes = create_city_meshes(voxel_array, vox_dict, meshsize=meshsize)
1159
+
1160
+ # Process each simulation grid
1161
+ for i, config in enumerate(sim_configs):
1162
+ sim_grid = config['sim_grid']
1163
+ if sim_grid is None or dem_grid is None:
1164
+ continue
1165
+
1166
+ z_offset = config.get('z_offset', 1.5)
1167
+ cmap_name = config.get('cmap_name', 'viridis')
1168
+ vmin = config.get('vmin', np.nanmin(sim_grid))
1169
+ vmax = config.get('vmax', np.nanmax(sim_grid))
1170
+ label = config.get('label', f'Simulation {i+1}')
1171
+
1172
+ print(f"Creating sim_grid surface mesh for {label}...")
1173
+ sim_mesh = create_sim_surface_mesh(
1174
+ sim_grid, dem_grid,
1175
+ meshsize=meshsize,
1176
+ z_offset=z_offset,
1177
+ cmap_name=cmap_name,
1178
+ vmin=vmin,
1179
+ vmax=vmax
1180
+ )
1181
+
1182
+ if sim_mesh is not None:
1183
+ meshes[f"sim_surface_{i}"] = sim_mesh
1184
+
1185
+ # Create colorbar for this simulation
1186
+ norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
1187
+ scalar_map = cm.ScalarMappable(norm=norm, cmap=cmap_name)
1188
+
1189
+ fig, ax = plt.subplots(figsize=(6, 1))
1190
+ plt.colorbar(scalar_map, cax=ax, orientation='horizontal', label=label)
1191
+ plt.tight_layout()
1192
+ plt.show()
1193
+
1194
+ # Export if filename provided
1195
+ if base_filename is not None:
1196
+ print(f"Exporting files to '{base_filename}.*' ...")
1197
+ os.makedirs(output_directory, exist_ok=True)
1198
+ export_meshes(meshes, output_directory, base_filename)
1199
+
1200
+ # Create and save multiple views
1201
+ print("Creating multiple views...")
1202
+ os.makedirs(output_directory, exist_ok=True)
1203
+ image_files = create_multi_view_scene(
1204
+ meshes,
1205
+ output_directory=output_directory,
1206
+ projection_type=projection_type,
1207
+ distance_factor=distance_factor
1208
+ )
1209
+
1210
+ # Display each view separately
1211
+ for view_name, img_file in image_files:
1212
+ plt.figure(figsize=(12, 8))
1213
+ img = plt.imread(img_file)
1214
+ plt.imshow(img)
1215
+ plt.title(view_name.replace('_', ' ').title(), pad=20)
1216
+ plt.axis('off')
1217
+ plt.show()
1218
+ plt.close()
1219
+
1220
+ return meshes
1221
+
1112
1222
  # def create_interactive_scene(meshes):
1113
1223
  # scene = trimesh.Scene()
1114
1224
  # scene.ambient_light = np.array([0.1, 0.1, 0.1, 1.0])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: voxcity
3
- Version: 0.3.24
3
+ Version: 0.3.27
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>
@@ -45,7 +45,7 @@ Requires-Dist: pycountry
45
45
  Requires-Dist: osm2geojson
46
46
  Requires-Dist: seaborn
47
47
  Requires-Dist: overturemaps
48
- Requires-Dist: protobuf==3.20.3
48
+ Requires-Dist: protobuf<=3.20.3
49
49
  Requires-Dist: timezonefinder
50
50
  Requires-Dist: astral
51
51
  Requires-Dist: osmnx
@@ -1,5 +1,5 @@
1
1
  voxcity/__init__.py,sha256=el9v3gfybHOF_GUYPeSOqN0-vCrTW0eU1mcvi0sEfeU,252
2
- voxcity/generator.py,sha256=dEhEGWF7Wgz8BwtX-eheAmn85VzhgJC9SckVQohVzzo,34406
2
+ voxcity/generator.py,sha256=rsS5Z77Esgomho9Bd3HRQeYlncvyEG1CEHUXAB_SHxw,35048
3
3
  voxcity/downloader/__init__.py,sha256=OgGcGxOXF4tjcEL6DhOnt13DYPTvOigUelp5xIpTqM0,171
4
4
  voxcity/downloader/eubucco.py,sha256=XCkkdEPNuWdrnuxzL80Ext37WsgiCiZGueb-aQV5rvI,14476
5
5
  voxcity/downloader/gee.py,sha256=hEN5OvQAltORYnrlPbmYcDequ6lKLmwyTbNaCZ81Vj8,16089
@@ -27,11 +27,11 @@ voxcity/simulator/view.py,sha256=zNbfTLQ2Jo0V5-rFA3-xamRjOuw3H3MBrLKpQp8x3hY,367
27
27
  voxcity/utils/__init_.py,sha256=nLYrj2huBbDBNMqfchCwexGP8Tlt9O_XluVDG7MoFkw,98
28
28
  voxcity/utils/lc.py,sha256=RwPd-VY3POV3gTrBhM7TubgGb9MCd3nVah_G8iUEF7k,11562
29
29
  voxcity/utils/material.py,sha256=Vt3IID5Ft54HNJcEC4zi31BCPqi_687X3CSp7rXaRVY,5907
30
- voxcity/utils/visualization.py,sha256=QgcEc6SZb4J4mtk45rRjwJ6JCvfrh1rPxrZhHveyDn8,49852
30
+ voxcity/utils/visualization.py,sha256=ufS6aMIaDUmFNTiqQS5If7SgHxMm6unKIIOkFdnSkOQ,54253
31
31
  voxcity/utils/weather.py,sha256=P6s1y_EstBL1OGP_MR_6u3vr-t6Uawg8uDckJnoI7FI,21482
32
- voxcity-0.3.24.dist-info/AUTHORS.rst,sha256=m82vkI5QokEGdcHof2OxK39lf81w1P58kG9ZNNAKS9U,175
33
- voxcity-0.3.24.dist-info/LICENSE,sha256=-hGliOFiwUrUSoZiB5WF90xXGqinKyqiDI2t6hrnam8,1087
34
- voxcity-0.3.24.dist-info/METADATA,sha256=s3WbdeRZe04Wo-_0-3WGZmX3Zd7AG0iuISi2Km5ROSo,25186
35
- voxcity-0.3.24.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
36
- voxcity-0.3.24.dist-info/top_level.txt,sha256=00b2U-LKfDllt6RL1R33MXie5MvxzUFye0NGD96t_8I,8
37
- voxcity-0.3.24.dist-info/RECORD,,
32
+ voxcity-0.3.27.dist-info/AUTHORS.rst,sha256=m82vkI5QokEGdcHof2OxK39lf81w1P58kG9ZNNAKS9U,175
33
+ voxcity-0.3.27.dist-info/LICENSE,sha256=-hGliOFiwUrUSoZiB5WF90xXGqinKyqiDI2t6hrnam8,1087
34
+ voxcity-0.3.27.dist-info/METADATA,sha256=-2DQaO2L5yJXuJ5tQv-sC6s-VIip3dcEhbpVtSUpjeo,25186
35
+ voxcity-0.3.27.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
36
+ voxcity-0.3.27.dist-info/top_level.txt,sha256=00b2U-LKfDllt6RL1R33MXie5MvxzUFye0NGD96t_8I,8
37
+ voxcity-0.3.27.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (75.8.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5