voxcity 0.7.0__py3-none-any.whl → 1.0.13__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.
Files changed (81) hide show
  1. voxcity/__init__.py +14 -14
  2. voxcity/downloader/ocean.py +559 -0
  3. voxcity/exporter/__init__.py +12 -12
  4. voxcity/exporter/cityles.py +633 -633
  5. voxcity/exporter/envimet.py +733 -728
  6. voxcity/exporter/magicavoxel.py +333 -333
  7. voxcity/exporter/netcdf.py +238 -238
  8. voxcity/exporter/obj.py +1480 -1480
  9. voxcity/generator/__init__.py +47 -44
  10. voxcity/generator/api.py +727 -675
  11. voxcity/generator/grids.py +394 -379
  12. voxcity/generator/io.py +94 -94
  13. voxcity/generator/pipeline.py +582 -282
  14. voxcity/generator/update.py +429 -0
  15. voxcity/generator/voxelizer.py +18 -6
  16. voxcity/geoprocessor/__init__.py +75 -75
  17. voxcity/geoprocessor/draw.py +1494 -1219
  18. voxcity/geoprocessor/merge_utils.py +91 -91
  19. voxcity/geoprocessor/mesh.py +806 -806
  20. voxcity/geoprocessor/network.py +708 -708
  21. voxcity/geoprocessor/raster/__init__.py +2 -0
  22. voxcity/geoprocessor/raster/buildings.py +435 -428
  23. voxcity/geoprocessor/raster/core.py +31 -0
  24. voxcity/geoprocessor/raster/export.py +93 -93
  25. voxcity/geoprocessor/raster/landcover.py +178 -51
  26. voxcity/geoprocessor/raster/raster.py +1 -1
  27. voxcity/geoprocessor/utils.py +824 -824
  28. voxcity/models.py +115 -113
  29. voxcity/simulator/solar/__init__.py +66 -43
  30. voxcity/simulator/solar/integration.py +336 -336
  31. voxcity/simulator/solar/sky.py +668 -0
  32. voxcity/simulator/solar/temporal.py +792 -434
  33. voxcity/simulator_gpu/__init__.py +115 -0
  34. voxcity/simulator_gpu/common/__init__.py +9 -0
  35. voxcity/simulator_gpu/common/geometry.py +11 -0
  36. voxcity/simulator_gpu/core.py +322 -0
  37. voxcity/simulator_gpu/domain.py +262 -0
  38. voxcity/simulator_gpu/environment.yml +11 -0
  39. voxcity/simulator_gpu/init_taichi.py +154 -0
  40. voxcity/simulator_gpu/integration.py +15 -0
  41. voxcity/simulator_gpu/kernels.py +56 -0
  42. voxcity/simulator_gpu/radiation.py +28 -0
  43. voxcity/simulator_gpu/raytracing.py +623 -0
  44. voxcity/simulator_gpu/sky.py +9 -0
  45. voxcity/simulator_gpu/solar/__init__.py +178 -0
  46. voxcity/simulator_gpu/solar/core.py +66 -0
  47. voxcity/simulator_gpu/solar/csf.py +1249 -0
  48. voxcity/simulator_gpu/solar/domain.py +561 -0
  49. voxcity/simulator_gpu/solar/epw.py +421 -0
  50. voxcity/simulator_gpu/solar/integration.py +2953 -0
  51. voxcity/simulator_gpu/solar/radiation.py +3019 -0
  52. voxcity/simulator_gpu/solar/raytracing.py +686 -0
  53. voxcity/simulator_gpu/solar/reflection.py +533 -0
  54. voxcity/simulator_gpu/solar/sky.py +907 -0
  55. voxcity/simulator_gpu/solar/solar.py +337 -0
  56. voxcity/simulator_gpu/solar/svf.py +446 -0
  57. voxcity/simulator_gpu/solar/volumetric.py +1151 -0
  58. voxcity/simulator_gpu/solar/voxcity.py +2953 -0
  59. voxcity/simulator_gpu/temporal.py +13 -0
  60. voxcity/simulator_gpu/utils.py +25 -0
  61. voxcity/simulator_gpu/view.py +32 -0
  62. voxcity/simulator_gpu/visibility/__init__.py +109 -0
  63. voxcity/simulator_gpu/visibility/geometry.py +278 -0
  64. voxcity/simulator_gpu/visibility/integration.py +808 -0
  65. voxcity/simulator_gpu/visibility/landmark.py +753 -0
  66. voxcity/simulator_gpu/visibility/view.py +944 -0
  67. voxcity/utils/__init__.py +11 -0
  68. voxcity/utils/classes.py +194 -0
  69. voxcity/utils/lc.py +80 -39
  70. voxcity/utils/shape.py +230 -0
  71. voxcity/visualizer/__init__.py +24 -24
  72. voxcity/visualizer/builder.py +43 -43
  73. voxcity/visualizer/grids.py +141 -141
  74. voxcity/visualizer/maps.py +187 -187
  75. voxcity/visualizer/renderer.py +1146 -928
  76. {voxcity-0.7.0.dist-info → voxcity-1.0.13.dist-info}/METADATA +56 -52
  77. voxcity-1.0.13.dist-info/RECORD +116 -0
  78. voxcity-0.7.0.dist-info/RECORD +0 -77
  79. {voxcity-0.7.0.dist-info → voxcity-1.0.13.dist-info}/WHEEL +0 -0
  80. {voxcity-0.7.0.dist-info → voxcity-1.0.13.dist-info}/licenses/AUTHORS.rst +0 -0
  81. {voxcity-0.7.0.dist-info → voxcity-1.0.13.dist-info}/licenses/LICENSE +0 -0
@@ -1,187 +1,187 @@
1
- from __future__ import annotations
2
-
3
- import numpy as np
4
- import matplotlib.pyplot as plt
5
- import matplotlib.colors as mcolors
6
- import seaborn as sns
7
- import contextily as ctx
8
- from shapely.geometry import Polygon
9
- from pyproj import CRS
10
-
11
- from ..geoprocessor.raster import (
12
- calculate_grid_size,
13
- create_coordinate_mesh,
14
- )
15
- from ..geoprocessor.utils import (
16
- initialize_geod,
17
- calculate_distance,
18
- normalize_to_one_meter,
19
- setup_transformer,
20
- transform_coords,
21
- )
22
- from ..utils.lc import get_land_cover_classes
23
-
24
-
25
- def plot_grid(grid, origin, adjusted_meshsize, u_vec, v_vec, transformer, vertices, data_type, vmin=None, vmax=None, color_map=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light', **kwargs):
26
- fig, ax = plt.subplots(figsize=(12, 12))
27
-
28
- if data_type == 'land_cover':
29
- land_cover_classes = kwargs.get('land_cover_classes')
30
- colors = [mcolors.to_rgb(f'#{r:02x}{g:02x}{b:02x}') for r, g, b in land_cover_classes.keys()]
31
- cmap = mcolors.ListedColormap(colors)
32
- norm = mcolors.BoundaryNorm(range(len(land_cover_classes)+1), cmap.N)
33
- elif data_type == 'building_height':
34
- masked_grid = np.ma.masked_array(grid, mask=(np.isnan(grid) | (grid == 0)))
35
- cmap = plt.cm.viridis
36
- if vmin is None:
37
- vmin = np.nanmin(masked_grid[masked_grid > 0])
38
- if vmax is None:
39
- vmax = np.nanmax(masked_grid)
40
- norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
41
- elif data_type == 'dem':
42
- cmap = plt.cm.terrain
43
- if vmin is None:
44
- vmin = np.nanmin(grid)
45
- if vmax is None:
46
- vmax = np.nanmax(grid)
47
- norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
48
- elif data_type == 'canopy_height':
49
- cmap = plt.cm.Greens
50
- if vmin is None:
51
- vmin = np.nanmin(grid)
52
- if vmax is None:
53
- vmax = np.nanmax(grid)
54
- norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
55
- elif data_type in ('green_view_index', 'sky_view_index'):
56
- cmap = plt.cm.get_cmap('BuPu_r').copy() if data_type == 'sky_view_index' else plt.cm.Greens
57
- if vmin is None:
58
- vmin = np.nanmin(grid)
59
- if vmax is None:
60
- vmax = np.nanmax(grid)
61
- norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
62
- else:
63
- cmap = plt.cm.viridis
64
- if vmin is None:
65
- vmin = np.nanmin(grid)
66
- if vmax is None:
67
- vmax = np.nanmax(grid)
68
- norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
69
-
70
- if color_map:
71
- cmap = sns.color_palette(color_map, as_cmap=True).copy()
72
-
73
- grid = grid.T
74
-
75
- for i in range(grid.shape[0]):
76
- for j in range(grid.shape[1]):
77
- cell = create_cell_polygon(origin, j, i, adjusted_meshsize, u_vec, v_vec) # type: ignore[name-defined]
78
- x, y = cell.exterior.xy
79
- x, y = zip(*[transformer.transform(lon, lat) for lat, lon in zip(x, y)])
80
- value = grid[i, j]
81
- if data_type == 'building_height':
82
- if np.isnan(value):
83
- ax.fill(x, y, alpha=alpha, fc='gray', ec='black' if edge else None, linewidth=0.1)
84
- elif value == 0:
85
- if edge:
86
- ax.plot(x, y, color='black', linewidth=0.1)
87
- elif value > 0:
88
- ax.fill(x, y, alpha=alpha, fc=cmap(norm(value)), ec='black' if edge else None, linewidth=0.1)
89
- elif data_type == 'canopy_height':
90
- color = cmap(norm(value))
91
- if value == 0:
92
- if edge:
93
- ax.plot(x, y, color='black', linewidth=0.1)
94
- else:
95
- ax.fill(x, y, alpha=alpha, fc=color, ec='black' if edge else None, linewidth=0.1)
96
- elif 'view' in data_type:
97
- if np.isnan(value):
98
- if edge:
99
- ax.plot(x, y, color='black', linewidth=0.1)
100
- elif value >= 0:
101
- ax.fill(x, y, alpha=alpha, fc=cmap(norm(value)), ec='black' if edge else None, linewidth=0.1)
102
- else:
103
- color = cmap(norm(value))
104
- ax.fill(x, y, alpha=alpha, fc=color, ec='black' if edge else None, linewidth=0.1)
105
-
106
- crs_epsg_3857 = CRS.from_epsg(3857)
107
- basemaps = {
108
- 'CartoDB dark': ctx.providers.CartoDB.DarkMatter,
109
- 'CartoDB light': ctx.providers.CartoDB.Positron,
110
- 'CartoDB voyager': ctx.providers.CartoDB.Voyager,
111
- 'CartoDB light no labels': ctx.providers.CartoDB.PositronNoLabels,
112
- 'CartoDB dark no labels': ctx.providers.CartoDB.DarkMatterNoLabels,
113
- }
114
- ctx.add_basemap(ax, crs=crs_epsg_3857, source=basemaps[basemap])
115
-
116
- all_coords = np.array(vertices)
117
- x, y = zip(*[transformer.transform(lon, lat) for lat, lon in all_coords])
118
- x_min, x_max = min(x), max(x)
119
- y_min, y_max = min(y), max(y)
120
- if x_min != x_max and y_min != y_max and buf != 0:
121
- dist_x = x_max - x_min
122
- dist_y = y_max - y_min
123
- ax.set_xlim(x_min - buf * dist_x, x_max + buf * dist_x)
124
- ax.set_ylim(y_min - buf * dist_y, y_max + buf * dist_y)
125
- else:
126
- ax.set_xlim(x_min, x_max)
127
- ax.set_ylim(y_min, y_max)
128
-
129
- plt.axis('off')
130
- plt.tight_layout()
131
- plt.show()
132
-
133
-
134
- def visualize_land_cover_grid_on_map(grid, rectangle_vertices, meshsize, source='Urbanwatch', vmin=None, vmax=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light'):
135
- geod = initialize_geod()
136
- land_cover_classes = get_land_cover_classes(source)
137
- vertex_0 = rectangle_vertices[0]; vertex_1 = rectangle_vertices[1]; vertex_3 = rectangle_vertices[3]
138
- dist_side_1 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_1[1], vertex_1[0])
139
- dist_side_2 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_3[1], vertex_3[0])
140
- side_1 = np.array(vertex_1) - np.array(vertex_0)
141
- side_2 = np.array(vertex_3) - np.array(vertex_0)
142
- u_vec = normalize_to_one_meter(side_1, dist_side_1)
143
- v_vec = normalize_to_one_meter(side_2, dist_side_2)
144
- origin = np.array(rectangle_vertices[0])
145
- grid_size, adjusted_meshsize = calculate_grid_size(side_1, side_2, u_vec, v_vec, meshsize)
146
- transformer = setup_transformer(CRS.from_epsg(4326), CRS.from_epsg(3857))
147
- plot_grid(grid, origin, adjusted_meshsize, u_vec, v_vec, transformer, rectangle_vertices, 'land_cover', alpha=alpha, buf=buf, edge=edge, basemap=basemap, land_cover_classes=land_cover_classes)
148
-
149
-
150
- def visualize_building_height_grid_on_map(building_height_grid, filtered_buildings, rectangle_vertices, meshsize, vmin=None, vmax=None, color_map=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light'):
151
- geod = initialize_geod()
152
- vertex_0, vertex_1, vertex_3 = rectangle_vertices[0], rectangle_vertices[1], rectangle_vertices[3]
153
- dist_side_1 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_1[1], vertex_1[0])
154
- dist_side_2 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_3[1], vertex_3[0])
155
- side_1 = np.array(vertex_1) - np.array(vertex_0)
156
- side_2 = np.array(vertex_3) - np.array(vertex_0)
157
- u_vec = normalize_to_one_meter(side_1, dist_side_1)
158
- v_vec = normalize_to_one_meter(side_2, dist_side_2)
159
- origin = np.array(rectangle_vertices[0])
160
- _, adjusted_meshsize = calculate_grid_size(side_1, side_2, u_vec, v_vec, meshsize)
161
- transformer = setup_transformer(CRS.from_epsg(4326), CRS.from_epsg(3857))
162
- plot_grid(building_height_grid, origin, adjusted_meshsize, u_vec, v_vec, transformer,
163
- rectangle_vertices, 'building_height', vmin=vmin, vmax=vmax, color_map=color_map, alpha=alpha, buf=buf, edge=edge, basemap=basemap, buildings=filtered_buildings)
164
-
165
-
166
- def visualize_numerical_grid_on_map(canopy_height_grid, rectangle_vertices, meshsize, type, vmin=None, vmax=None, color_map=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light'):
167
- geod = initialize_geod()
168
- vertex_0, vertex_1, vertex_3 = rectangle_vertices[0], rectangle_vertices[1], rectangle_vertices[3]
169
- dist_side_1 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_1[1], vertex_1[0])
170
- dist_side_2 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_3[1], vertex_3[0])
171
- side_1 = np.array(vertex_1) - np.array(vertex_0)
172
- side_2 = np.array(vertex_3) - np.array(vertex_0)
173
- u_vec = normalize_to_one_meter(side_1, dist_side_1)
174
- v_vec = normalize_to_one_meter(side_2, dist_side_2)
175
- origin = np.array(rectangle_vertices[0])
176
- _, adjusted_meshsize = calculate_grid_size(side_1, side_2, u_vec, v_vec, meshsize)
177
- transformer = setup_transformer(CRS.from_epsg(4326), CRS.from_epsg(3857))
178
- plot_grid(canopy_height_grid, origin, adjusted_meshsize, u_vec, v_vec, transformer,
179
- rectangle_vertices, type, vmin=vmin, vmax=vmax, color_map=color_map, alpha=alpha, buf=buf, edge=edge, basemap=basemap)
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
1
+ from __future__ import annotations
2
+
3
+ import numpy as np
4
+ import matplotlib.pyplot as plt
5
+ import matplotlib.colors as mcolors
6
+ import seaborn as sns
7
+ import contextily as ctx
8
+ from shapely.geometry import Polygon
9
+ from pyproj import CRS
10
+
11
+ from ..geoprocessor.raster import (
12
+ calculate_grid_size,
13
+ create_coordinate_mesh,
14
+ )
15
+ from ..geoprocessor.utils import (
16
+ initialize_geod,
17
+ calculate_distance,
18
+ normalize_to_one_meter,
19
+ setup_transformer,
20
+ transform_coords,
21
+ )
22
+ from ..utils.lc import get_land_cover_classes
23
+
24
+
25
+ def plot_grid(grid, origin, adjusted_meshsize, u_vec, v_vec, transformer, vertices, data_type, vmin=None, vmax=None, color_map=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light', **kwargs):
26
+ fig, ax = plt.subplots(figsize=(12, 12))
27
+
28
+ if data_type == 'land_cover':
29
+ land_cover_classes = kwargs.get('land_cover_classes')
30
+ colors = [mcolors.to_rgb(f'#{r:02x}{g:02x}{b:02x}') for r, g, b in land_cover_classes.keys()]
31
+ cmap = mcolors.ListedColormap(colors)
32
+ norm = mcolors.BoundaryNorm(range(len(land_cover_classes)+1), cmap.N)
33
+ elif data_type == 'building_height':
34
+ masked_grid = np.ma.masked_array(grid, mask=(np.isnan(grid) | (grid == 0)))
35
+ cmap = plt.cm.viridis
36
+ if vmin is None:
37
+ vmin = np.nanmin(masked_grid[masked_grid > 0])
38
+ if vmax is None:
39
+ vmax = np.nanmax(masked_grid)
40
+ norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
41
+ elif data_type == 'dem':
42
+ cmap = plt.cm.terrain
43
+ if vmin is None:
44
+ vmin = np.nanmin(grid)
45
+ if vmax is None:
46
+ vmax = np.nanmax(grid)
47
+ norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
48
+ elif data_type == 'canopy_height':
49
+ cmap = plt.cm.Greens
50
+ if vmin is None:
51
+ vmin = np.nanmin(grid)
52
+ if vmax is None:
53
+ vmax = np.nanmax(grid)
54
+ norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
55
+ elif data_type in ('green_view_index', 'sky_view_index'):
56
+ cmap = plt.cm.get_cmap('BuPu_r').copy() if data_type == 'sky_view_index' else plt.cm.Greens
57
+ if vmin is None:
58
+ vmin = np.nanmin(grid)
59
+ if vmax is None:
60
+ vmax = np.nanmax(grid)
61
+ norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
62
+ else:
63
+ cmap = plt.cm.viridis
64
+ if vmin is None:
65
+ vmin = np.nanmin(grid)
66
+ if vmax is None:
67
+ vmax = np.nanmax(grid)
68
+ norm = mcolors.Normalize(vmin=vmin, vmax=vmax)
69
+
70
+ if color_map:
71
+ cmap = sns.color_palette(color_map, as_cmap=True).copy()
72
+
73
+ grid = grid.T
74
+
75
+ for i in range(grid.shape[0]):
76
+ for j in range(grid.shape[1]):
77
+ cell = create_cell_polygon(origin, j, i, adjusted_meshsize, u_vec, v_vec) # type: ignore[name-defined]
78
+ x, y = cell.exterior.xy
79
+ x, y = zip(*[transformer.transform(lon, lat) for lat, lon in zip(x, y)])
80
+ value = grid[i, j]
81
+ if data_type == 'building_height':
82
+ if np.isnan(value):
83
+ ax.fill(x, y, alpha=alpha, fc='gray', ec='black' if edge else None, linewidth=0.1)
84
+ elif value == 0:
85
+ if edge:
86
+ ax.plot(x, y, color='black', linewidth=0.1)
87
+ elif value > 0:
88
+ ax.fill(x, y, alpha=alpha, fc=cmap(norm(value)), ec='black' if edge else None, linewidth=0.1)
89
+ elif data_type == 'canopy_height':
90
+ color = cmap(norm(value))
91
+ if value == 0:
92
+ if edge:
93
+ ax.plot(x, y, color='black', linewidth=0.1)
94
+ else:
95
+ ax.fill(x, y, alpha=alpha, fc=color, ec='black' if edge else None, linewidth=0.1)
96
+ elif 'view' in data_type:
97
+ if np.isnan(value):
98
+ if edge:
99
+ ax.plot(x, y, color='black', linewidth=0.1)
100
+ elif value >= 0:
101
+ ax.fill(x, y, alpha=alpha, fc=cmap(norm(value)), ec='black' if edge else None, linewidth=0.1)
102
+ else:
103
+ color = cmap(norm(value))
104
+ ax.fill(x, y, alpha=alpha, fc=color, ec='black' if edge else None, linewidth=0.1)
105
+
106
+ crs_epsg_3857 = CRS.from_epsg(3857)
107
+ basemaps = {
108
+ 'CartoDB dark': ctx.providers.CartoDB.DarkMatter,
109
+ 'CartoDB light': ctx.providers.CartoDB.Positron,
110
+ 'CartoDB voyager': ctx.providers.CartoDB.Voyager,
111
+ 'CartoDB light no labels': ctx.providers.CartoDB.PositronNoLabels,
112
+ 'CartoDB dark no labels': ctx.providers.CartoDB.DarkMatterNoLabels,
113
+ }
114
+ ctx.add_basemap(ax, crs=crs_epsg_3857, source=basemaps[basemap])
115
+
116
+ all_coords = np.array(vertices)
117
+ x, y = zip(*[transformer.transform(lon, lat) for lat, lon in all_coords])
118
+ x_min, x_max = min(x), max(x)
119
+ y_min, y_max = min(y), max(y)
120
+ if x_min != x_max and y_min != y_max and buf != 0:
121
+ dist_x = x_max - x_min
122
+ dist_y = y_max - y_min
123
+ ax.set_xlim(x_min - buf * dist_x, x_max + buf * dist_x)
124
+ ax.set_ylim(y_min - buf * dist_y, y_max + buf * dist_y)
125
+ else:
126
+ ax.set_xlim(x_min, x_max)
127
+ ax.set_ylim(y_min, y_max)
128
+
129
+ plt.axis('off')
130
+ plt.tight_layout()
131
+ plt.show()
132
+
133
+
134
+ def visualize_land_cover_grid_on_map(grid, rectangle_vertices, meshsize, source='Urbanwatch', vmin=None, vmax=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light'):
135
+ geod = initialize_geod()
136
+ land_cover_classes = get_land_cover_classes(source)
137
+ vertex_0 = rectangle_vertices[0]; vertex_1 = rectangle_vertices[1]; vertex_3 = rectangle_vertices[3]
138
+ dist_side_1 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_1[1], vertex_1[0])
139
+ dist_side_2 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_3[1], vertex_3[0])
140
+ side_1 = np.array(vertex_1) - np.array(vertex_0)
141
+ side_2 = np.array(vertex_3) - np.array(vertex_0)
142
+ u_vec = normalize_to_one_meter(side_1, dist_side_1)
143
+ v_vec = normalize_to_one_meter(side_2, dist_side_2)
144
+ origin = np.array(rectangle_vertices[0])
145
+ grid_size, adjusted_meshsize = calculate_grid_size(side_1, side_2, u_vec, v_vec, meshsize)
146
+ transformer = setup_transformer(CRS.from_epsg(4326), CRS.from_epsg(3857))
147
+ plot_grid(grid, origin, adjusted_meshsize, u_vec, v_vec, transformer, rectangle_vertices, 'land_cover', alpha=alpha, buf=buf, edge=edge, basemap=basemap, land_cover_classes=land_cover_classes)
148
+
149
+
150
+ def visualize_building_height_grid_on_map(building_height_grid, filtered_buildings, rectangle_vertices, meshsize, vmin=None, vmax=None, color_map=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light'):
151
+ geod = initialize_geod()
152
+ vertex_0, vertex_1, vertex_3 = rectangle_vertices[0], rectangle_vertices[1], rectangle_vertices[3]
153
+ dist_side_1 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_1[1], vertex_1[0])
154
+ dist_side_2 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_3[1], vertex_3[0])
155
+ side_1 = np.array(vertex_1) - np.array(vertex_0)
156
+ side_2 = np.array(vertex_3) - np.array(vertex_0)
157
+ u_vec = normalize_to_one_meter(side_1, dist_side_1)
158
+ v_vec = normalize_to_one_meter(side_2, dist_side_2)
159
+ origin = np.array(rectangle_vertices[0])
160
+ _, adjusted_meshsize = calculate_grid_size(side_1, side_2, u_vec, v_vec, meshsize)
161
+ transformer = setup_transformer(CRS.from_epsg(4326), CRS.from_epsg(3857))
162
+ plot_grid(building_height_grid, origin, adjusted_meshsize, u_vec, v_vec, transformer,
163
+ rectangle_vertices, 'building_height', vmin=vmin, vmax=vmax, color_map=color_map, alpha=alpha, buf=buf, edge=edge, basemap=basemap, buildings=filtered_buildings)
164
+
165
+
166
+ def visualize_numerical_grid_on_map(canopy_height_grid, rectangle_vertices, meshsize, type, vmin=None, vmax=None, color_map=None, alpha=0.5, buf=0.2, edge=True, basemap='CartoDB light'):
167
+ geod = initialize_geod()
168
+ vertex_0, vertex_1, vertex_3 = rectangle_vertices[0], rectangle_vertices[1], rectangle_vertices[3]
169
+ dist_side_1 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_1[1], vertex_1[0])
170
+ dist_side_2 = calculate_distance(geod, vertex_0[1], vertex_0[0], vertex_3[1], vertex_3[0])
171
+ side_1 = np.array(vertex_1) - np.array(vertex_0)
172
+ side_2 = np.array(vertex_3) - np.array(vertex_0)
173
+ u_vec = normalize_to_one_meter(side_1, dist_side_1)
174
+ v_vec = normalize_to_one_meter(side_2, dist_side_2)
175
+ origin = np.array(rectangle_vertices[0])
176
+ _, adjusted_meshsize = calculate_grid_size(side_1, side_2, u_vec, v_vec, meshsize)
177
+ transformer = setup_transformer(CRS.from_epsg(4326), CRS.from_epsg(3857))
178
+ plot_grid(canopy_height_grid, origin, adjusted_meshsize, u_vec, v_vec, transformer,
179
+ rectangle_vertices, type, vmin=vmin, vmax=vmax, color_map=color_map, alpha=alpha, buf=buf, edge=edge, basemap=basemap)
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+