rslearn.dataset.window¶
window ¶
rslearn windows.
WindowLayerData ¶
Layer data for retrieved layers specifying relevant items in the data source.
This stores the outputs from dataset prepare for a given layer.
Source code in rslearn/dataset/window.py
serialize ¶
Serialize a WindowLayerData is a JSON-encodable dict.
Returns:
| Type | Description |
|---|---|
dict
|
the JSON-encodable dict |
Source code in rslearn/dataset/window.py
deserialize
staticmethod
¶
deserialize(d: dict) -> WindowLayerData
Deserialize a WindowLayerData.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
dict
|
a JSON dict |
required |
Returns:
| Type | Description |
|---|---|
WindowLayerData
|
the WindowLayerData |
Source code in rslearn/dataset/window.py
Window ¶
A spatiotemporal window in an rslearn dataset.
Source code in rslearn/dataset/window.py
131 132 133 134 135 136 137 138 139 140 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 181 182 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 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 | |
data
property
¶
data: WindowDataStorage
The bound WindowDataStorage for materialized raster/vector data.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
if no WindowDataStorage has been bound to this window. |
load_layer_datas ¶
load_layer_datas() -> dict[str, WindowLayerData]
Load layer datas describing items in retrieved layers from items.json.
save_layer_datas ¶
save_layer_datas(layer_datas: dict[str, WindowLayerData]) -> None
list_completed_layers ¶
List the completed (materialized) item groups for this window.
Returns:
| Type | Description |
|---|---|
list[tuple[str, int]]
|
a list of (layer_name, group_idx) tuples identifying completed item groups. |
Source code in rslearn/dataset/window.py
get_layer_dir ¶
Get the directory containing materialized data for the specified item group.
.. deprecated::
This returns the per-item-group layout used by
:class:rslearn.dataset.window_storage.PerItemGroupStorage. It is
not valid for other WindowDataStorage implementations. Read
and write materialized data through WindowDataStorage instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
the layer name. |
required |
group_idx
|
int
|
the item group index within the layer (default 0). |
0
|
Returns:
| Type | Description |
|---|---|
UPath
|
the path where data for this item group is or should be materialized. |
Source code in rslearn/dataset/window.py
is_layer_completed ¶
Check whether the specified item group is completed (materialized).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
the layer name. |
required |
group_idx
|
int
|
the item group index within the layer (default 0). |
0
|
Returns:
| Type | Description |
|---|---|
bool
|
whether the item group is completed. |
Source code in rslearn/dataset/window.py
mark_layer_completed ¶
Mark the specified item group completed.
This must be done after the contents of the item group have been written. If a layer has multiple item groups, the caller should wait until the contents of all groups have been written before marking them completed; this is because, when materializing a window, we skip materialization if the first item group (group_idx=0) is marked completed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
the layer name. |
required |
group_idx
|
int
|
the item group index within the layer (default 0). |
0
|
Source code in rslearn/dataset/window.py
get_raster_dir ¶
Get the directory where the raster is materialized for a specific item group.
.. deprecated::
This returns the per-item-group layout used by
:class:rslearn.dataset.window_storage.PerItemGroupStorage. It is
not valid for other WindowDataStorage implementations. Read
and write raster data through WindowDataStorage instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
the layer name. |
required |
bands
|
list[str]
|
the bands in the raster. It should match a band set defined for this layer. |
required |
group_idx
|
int
|
the item group index within the layer (default 0). |
0
|
Returns:
| Type | Description |
|---|---|
UPath
|
the directory containing the raster for this item group. |
Source code in rslearn/dataset/window.py
get_metadata ¶
Returns the window metadata dictionary.
Source code in rslearn/dataset/window.py
save ¶
from_metadata
staticmethod
¶
from_metadata(storage: WindowStorage, metadata: dict[str, Any]) -> Window
Create a Window from the WindowStorage and the window's metadata dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
storage
|
WindowStorage
|
the WindowStorage for the underlying dataset. |
required |
metadata
|
dict[str, Any]
|
the window metadata. |
required |
Returns:
| Type | Description |
|---|---|
Window
|
the Window |
Source code in rslearn/dataset/window.py
get_window_root
staticmethod
¶
Gets the root directory of a window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds_path
|
UPath
|
the dataset root directory |
required |
group
|
str
|
the group of the window |
required |
name
|
str
|
the name of the window |
required |
Returns: the path for the window
Source code in rslearn/dataset/window.py
get_layer_and_group_from_dir_name ¶
Parse a layer directory name (item group specifier) into layer name and group index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_dir_name
|
str
|
the item group specifier to parse. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, int]
|
a tuple (layer_name, group_idx). |