rslearn.dataset.materialize¶
materialize ¶
Classes to implement dataset materialization.
Materializer ¶
An abstract class that materializes data from a tile store.
Source code in rslearn/dataset/materialize.py
materialize ¶
materialize(tile_store: TileStoreWithLayer, window: Window, layer_name: str, layer_cfg: LayerConfig, item_groups: list[list[ItemType]], group_time_ranges: list[tuple[datetime, datetime] | None] | None = None) -> None
Materialize portions of items corresponding to this window into the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile_store
|
TileStoreWithLayer
|
the tile store where the items have been ingested (unprefixed) |
required |
window
|
Window
|
the window to materialize |
required |
layer_name
|
str
|
the name of the layer to materialize |
required |
layer_cfg
|
LayerConfig
|
the configuration of the layer to materialize |
required |
item_groups
|
list[list[ItemType]]
|
the items associated with this window and layer |
required |
group_time_ranges
|
list[tuple[datetime, datetime] | None] | None
|
optional request time range for each item group |
None
|
Source code in rslearn/dataset/materialize.py
RasterMaterializer ¶
Bases: Materializer
A Materializer for raster data.
Source code in rslearn/dataset/materialize.py
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 | |
materialize ¶
materialize(tile_store: TileStoreWithLayer, window: Window, layer_name: str, layer_cfg: LayerConfig, item_groups: list[list[ItemType]], group_time_ranges: list[tuple[datetime, datetime] | None] | None = None) -> None
Materialize portions of items corresponding to this window into the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile_store
|
TileStoreWithLayer
|
the tile store where the items have been ingested |
required |
window
|
Window
|
the window to materialize |
required |
layer_name
|
str
|
name of the layer to materialize |
required |
layer_cfg
|
LayerConfig
|
the configuration of the layer to materialize |
required |
item_groups
|
list[list[ItemType]]
|
the items associated with this window and layer |
required |
group_time_ranges
|
list[tuple[datetime, datetime] | None] | None
|
optional request time range for each item group |
None
|
Source code in rslearn/dataset/materialize.py
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 | |
VectorMaterializer ¶
Bases: Materializer
A Materializer for vector data.
Source code in rslearn/dataset/materialize.py
materialize ¶
materialize(tile_store: TileStoreWithLayer, window: Window, layer_name: str, layer_cfg: LayerConfig, item_groups: list[list[ItemType]], group_time_ranges: list[tuple[datetime, datetime] | None] | None = None) -> None
Materialize portions of items corresponding to this window into the dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile_store
|
TileStoreWithLayer
|
the tile store where the items have been ingested (unprefixed) |
required |
window
|
Window
|
the window to materialize |
required |
layer_name
|
str
|
the layer to materialize |
required |
layer_cfg
|
LayerConfig
|
the configuration of the layer to materialize |
required |
item_groups
|
list[list[ItemType]]
|
the items associated with this window and layer |
required |
group_time_ranges
|
list[tuple[datetime, datetime] | None] | None
|
unused for vector materialization |
None
|
Source code in rslearn/dataset/materialize.py
resolve_nodata_value ¶
resolve_nodata_value(tile_store: TileStoreWithLayer, items: list[ItemType], bands: list[str]) -> int | float | None
Resolve scalar nodata value from the tile store metadata.
Probes the first item that has matching bands and reads nodata from the raster file header (no pixel data is read). An error is raised if different assets have different nodata values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tile_store
|
TileStoreWithLayer
|
the tile store to query. |
required |
items
|
list[ItemType]
|
candidate items (from one or more item groups). |
required |
bands
|
list[str]
|
the requested band names. |
required |
Returns:
| Type | Description |
|---|---|
int | float | None
|
A scalar nodata value, or |
Source code in rslearn/dataset/materialize.py
build_composite ¶
build_composite(group: list[ItemType], compositor: Compositor, tile_store: TileStoreWithLayer, layer_cfg: LayerConfig, band_cfg: BandSetConfig, projection: Projection, bounds: PixelBounds, remapper: Remapper | None, request_time_range: tuple[datetime, datetime] | None = None) -> RasterArray
Build a composite for specified bands from items in the group.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
group
|
list[ItemType]
|
list of items to composite together |
required |
compositor
|
Compositor
|
Compositor instance that implements the compositing logic. |
required |
tile_store
|
TileStoreWithLayer
|
tile store containing the raster data |
required |
layer_cfg
|
LayerConfig
|
the configuration of the layer to materialize |
required |
band_cfg
|
BandSetConfig
|
the configuration of the layer to materialize. Contains the bands to process. |
required |
projection
|
Projection
|
spatial projection for the composite |
required |
bounds
|
PixelBounds
|
pixel bounds defining the spatial extent of the composite |
required |
remapper
|
Remapper | None
|
remapper to apply to pixel values, or None |
required |
request_time_range
|
tuple[datetime, datetime] | None
|
optional request time range, passed through to compositing method. |
None
|
Returns:
| Type | Description |
|---|---|
RasterArray
|
A RasterArray produced by the chosen compositing method. |