voxcity 0.6.4__py3-none-any.whl → 0.6.6__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.
- voxcity/exporter/cityles.py +33 -10
- voxcity/geoprocessor/__init__.py +6 -6
- voxcity/simulator/view.py +2285 -2238
- {voxcity-0.6.4.dist-info → voxcity-0.6.6.dist-info}/METADATA +534 -537
- {voxcity-0.6.4.dist-info → voxcity-0.6.6.dist-info}/RECORD +9 -10
- {voxcity-0.6.4.dist-info → voxcity-0.6.6.dist-info}/WHEEL +1 -2
- voxcity-0.6.4.dist-info/top_level.txt +0 -1
- {voxcity-0.6.4.dist-info/licenses → voxcity-0.6.6.dist-info}/AUTHORS.rst +0 -0
- {voxcity-0.6.4.dist-info/licenses → voxcity-0.6.6.dist-info}/LICENSE +0 -0
voxcity/exporter/cityles.py
CHANGED
|
@@ -190,7 +190,7 @@ def _build_index_to_cityles_map(land_cover_source):
|
|
|
190
190
|
|
|
191
191
|
|
|
192
192
|
def export_topog(building_height_grid, building_id_grid, output_path,
|
|
193
|
-
building_material='default'):
|
|
193
|
+
building_material='default', cityles_landuse_grid=None):
|
|
194
194
|
"""
|
|
195
195
|
Export topog.txt file for CityLES
|
|
196
196
|
|
|
@@ -211,8 +211,9 @@ def export_topog(building_height_grid, building_id_grid, output_path,
|
|
|
211
211
|
material_code = BUILDING_MATERIAL_MAPPING.get(building_material,
|
|
212
212
|
BUILDING_MATERIAL_MAPPING['default'])
|
|
213
213
|
|
|
214
|
-
#
|
|
215
|
-
|
|
214
|
+
# Count only cells with building height > 0
|
|
215
|
+
building_mask = building_height_grid > 0
|
|
216
|
+
n_buildings = int(np.count_nonzero(building_mask))
|
|
216
217
|
|
|
217
218
|
with open(filename, 'w') as f:
|
|
218
219
|
# Write number of buildings
|
|
@@ -225,8 +226,17 @@ def export_topog(building_height_grid, building_id_grid, output_path,
|
|
|
225
226
|
i_1based = i + 1
|
|
226
227
|
j_1based = j + 1
|
|
227
228
|
height = float(building_height_grid[j, i])
|
|
229
|
+
# Decide material code per cell
|
|
230
|
+
if cityles_landuse_grid is not None:
|
|
231
|
+
cell_lu = int(cityles_landuse_grid[j, i])
|
|
232
|
+
material_code_cell = cell_lu + 100
|
|
233
|
+
else:
|
|
234
|
+
if height > 0:
|
|
235
|
+
material_code_cell = material_code
|
|
236
|
+
else:
|
|
237
|
+
material_code_cell = 102
|
|
228
238
|
# Format: i j height material_code depth1 depth2 changed_material
|
|
229
|
-
f.write(f"{i_1based} {j_1based} {height:.1f} {
|
|
239
|
+
f.write(f"{i_1based} {j_1based} {height:.1f} {material_code_cell} 0.0 0.0 102\n")
|
|
230
240
|
|
|
231
241
|
|
|
232
242
|
def export_landuse(land_cover_grid, output_path, land_cover_source=None):
|
|
@@ -253,6 +263,8 @@ def export_landuse(land_cover_grid, output_path, land_cover_source=None):
|
|
|
253
263
|
|
|
254
264
|
# Create mapping statistics
|
|
255
265
|
mapping_stats = {}
|
|
266
|
+
# Prepare grid to return
|
|
267
|
+
cityles_landuse_grid = np.zeros((ny, nx), dtype=int)
|
|
256
268
|
|
|
257
269
|
with open(filename, 'w') as f:
|
|
258
270
|
# Write in row-major order (j varies first, then i)
|
|
@@ -262,6 +274,8 @@ def export_landuse(land_cover_grid, output_path, land_cover_source=None):
|
|
|
262
274
|
cityles_code = index_to_code.get(idx, 4)
|
|
263
275
|
f.write(f"{cityles_code}\n")
|
|
264
276
|
|
|
277
|
+
cityles_landuse_grid[j, i] = cityles_code
|
|
278
|
+
|
|
265
279
|
# Track mapping statistics
|
|
266
280
|
if idx not in mapping_stats:
|
|
267
281
|
mapping_stats[idx] = {'cityles_code': cityles_code, 'count': 0}
|
|
@@ -276,6 +290,8 @@ def export_landuse(land_cover_grid, output_path, land_cover_source=None):
|
|
|
276
290
|
class_name = class_names[idx] if 0 <= idx < len(class_names) else 'Unknown'
|
|
277
291
|
print(f" {idx}: {class_name} -> CityLES {stats['cityles_code']}: "
|
|
278
292
|
f"{stats['count']} cells ({percentage:.1f}%)")
|
|
293
|
+
|
|
294
|
+
return cityles_landuse_grid
|
|
279
295
|
|
|
280
296
|
|
|
281
297
|
def export_dem(dem_grid, output_path):
|
|
@@ -324,8 +340,9 @@ def export_vmap(canopy_height_grid, output_path, tree_base_ratio=0.3, tree_type=
|
|
|
324
340
|
ny, nx = canopy_height_grid.shape
|
|
325
341
|
tree_code = TREE_TYPE_MAPPING.get(tree_type, TREE_TYPE_MAPPING['default'])
|
|
326
342
|
|
|
327
|
-
#
|
|
328
|
-
|
|
343
|
+
# Count only cells with canopy height > 0
|
|
344
|
+
vegetation_mask = canopy_height_grid > 0
|
|
345
|
+
n_trees = int(np.count_nonzero(vegetation_mask))
|
|
329
346
|
|
|
330
347
|
with open(filename, 'w') as f:
|
|
331
348
|
# Write number of trees
|
|
@@ -432,11 +449,17 @@ def export_cityles(building_height_grid, building_id_grid, canopy_height_grid,
|
|
|
432
449
|
print(f"Land cover source: {land_cover_source}")
|
|
433
450
|
|
|
434
451
|
# Export individual files
|
|
435
|
-
print("\nExporting topog.txt...")
|
|
436
|
-
export_topog(building_height_grid, building_id_grid, output_path, building_material)
|
|
437
|
-
|
|
438
452
|
print("\nExporting landuse.txt...")
|
|
439
|
-
export_landuse(land_cover_grid, output_path, land_cover_source)
|
|
453
|
+
cityles_landuse_grid = export_landuse(land_cover_grid, output_path, land_cover_source)
|
|
454
|
+
|
|
455
|
+
print("\nExporting topog.txt...")
|
|
456
|
+
export_topog(
|
|
457
|
+
building_height_grid,
|
|
458
|
+
building_id_grid,
|
|
459
|
+
output_path,
|
|
460
|
+
building_material,
|
|
461
|
+
cityles_landuse_grid=cityles_landuse_grid,
|
|
462
|
+
)
|
|
440
463
|
|
|
441
464
|
print("\nExporting dem.txt...")
|
|
442
465
|
export_dem(dem_grid, output_path)
|
voxcity/geoprocessor/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
from .draw import *
|
|
2
|
-
from .grid import *
|
|
3
|
-
from .utils import *
|
|
4
|
-
from .network import *
|
|
5
|
-
from .polygon import *
|
|
6
|
-
from .mesh import *
|
|
1
|
+
from .draw import *
|
|
2
|
+
from .grid import *
|
|
3
|
+
from .utils import *
|
|
4
|
+
from .network import *
|
|
5
|
+
from .polygon import *
|
|
6
|
+
from .mesh import *
|