Water and 3MF parts¶
satprint.water
¶
Water map for multi-color prints: which terrain grid cells are water.
Water shapes come from the water layer of the same OpenFreeMap vector
tiles the buildings use (sea, rivers, lakes, ponds). Where the sea was
flattened to 0 m, the flattened cells count as water too, so a coast still
colors when the tiles are unavailable.
level_water(hm, tiles)
¶
hm with each lake, pond, reservoir and sea surface flattened to its shore.
Elevation data over water is unreliable: radar returns and void filling leave noise, and a lake in a steep valley can read tens of meters above its shore, which prints as a raised plateau. Each water body is set to the 10th percentile of the ground along its shore, the lower shore, and only ever lowered, so a body the data already shows flat is unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hm
|
Heightmap
|
a heightmap with a bounding box. |
required |
tiles
|
list[tuple[int, int, int, bytes]]
|
vector tiles covering it, as :meth: |
required |
Returns:
| Type | Description |
|---|---|
Heightmap
|
a new heightmap, or |
Source code in satprint/water.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
multicolor_parts(polygons, bbox, relief_mm, width_mm, depth_mm, base_mm, sea_level_flat=False, buildings=None, frame=None, roads=None, bridges=None)
¶
The 3MF parts, land, water, buildings, roads and border, and the water mask.
Bridges go in the roads part, so they print in the road color. Parts
without geometry are left out; :func:write_3mf numbers the filaments by
color in this order: land 1, water 2, then buildings and the gray of roads
and border as present.
Returns:
| Type | Description |
|---|---|
tuple[list[tuple[str, Mesh, str]], ndarray]
|
([(name, mesh, color), ...] for :func: |
Source code in satprint/water.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
water_from_vector_tiles(tiles)
¶
Water polygons, in lon/lat, from the tiles' water layer.
Source code in satprint/water.py
56 57 58 59 60 61 62 | |
water_mask(polygons, bbox, relief_mm, width_mm, depth_mm, sea_level_flat=False)
¶
(rows-1, cols-1) boolean grid: True where a terrain cell is water.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
polygons
|
list[Polygon]
|
water shapes in lon/lat. |
required |
bbox
|
BBox
|
area the block covers. |
required |
relief_mm
|
ndarray
|
the relief passed to :func: |
required |
width_mm
|
float
|
block width. |
required |
depth_mm
|
float
|
block depth. |
required |
sea_level_flat
|
bool
|
the sea was flattened to the lowest relief, so cells lying flat there count as water. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
the mask, row 0 north, as the heightmap. |
Source code in satprint/water.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
water_zoom(bbox)
¶
Highest vector-tile zoom (8-14) covering bbox in MAX_WATER_TILES.
A city reuses the zoom-14 tiles its buildings came from.
Source code in satprint/water.py
45 46 47 48 49 50 51 52 53 | |