rslearn 0.0.1__py3-none-any.whl → 0.0.21__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.
- rslearn/arg_parser.py +31 -0
- rslearn/config/__init__.py +6 -12
- rslearn/config/dataset.py +520 -401
- rslearn/const.py +9 -15
- rslearn/data_sources/__init__.py +8 -23
- rslearn/data_sources/aws_landsat.py +242 -98
- rslearn/data_sources/aws_open_data.py +111 -151
- rslearn/data_sources/aws_sentinel1.py +131 -0
- rslearn/data_sources/climate_data_store.py +471 -0
- rslearn/data_sources/copernicus.py +884 -12
- rslearn/data_sources/data_source.py +43 -12
- rslearn/data_sources/earthdaily.py +484 -0
- rslearn/data_sources/earthdata_srtm.py +282 -0
- rslearn/data_sources/eurocrops.py +242 -0
- rslearn/data_sources/gcp_public_data.py +578 -222
- rslearn/data_sources/google_earth_engine.py +461 -135
- rslearn/data_sources/local_files.py +219 -150
- rslearn/data_sources/openstreetmap.py +51 -89
- rslearn/data_sources/planet.py +24 -60
- rslearn/data_sources/planet_basemap.py +275 -0
- rslearn/data_sources/planetary_computer.py +798 -0
- rslearn/data_sources/usda_cdl.py +195 -0
- rslearn/data_sources/usgs_landsat.py +115 -83
- rslearn/data_sources/utils.py +249 -61
- rslearn/data_sources/vector_source.py +1 -0
- rslearn/data_sources/worldcereal.py +449 -0
- rslearn/data_sources/worldcover.py +144 -0
- rslearn/data_sources/worldpop.py +153 -0
- rslearn/data_sources/xyz_tiles.py +150 -107
- rslearn/dataset/__init__.py +8 -2
- rslearn/dataset/add_windows.py +2 -2
- rslearn/dataset/dataset.py +40 -51
- rslearn/dataset/handler_summaries.py +131 -0
- rslearn/dataset/manage.py +313 -74
- rslearn/dataset/materialize.py +431 -107
- rslearn/dataset/remap.py +29 -4
- rslearn/dataset/storage/__init__.py +1 -0
- rslearn/dataset/storage/file.py +202 -0
- rslearn/dataset/storage/storage.py +140 -0
- rslearn/dataset/window.py +181 -44
- rslearn/lightning_cli.py +454 -0
- rslearn/log_utils.py +24 -0
- rslearn/main.py +384 -181
- rslearn/models/anysat.py +215 -0
- rslearn/models/attention_pooling.py +177 -0
- rslearn/models/clay/clay.py +231 -0
- rslearn/models/clay/configs/metadata.yaml +295 -0
- rslearn/models/clip.py +68 -0
- rslearn/models/component.py +111 -0
- rslearn/models/concatenate_features.py +103 -0
- rslearn/models/conv.py +63 -0
- rslearn/models/croma.py +306 -0
- rslearn/models/detr/__init__.py +5 -0
- rslearn/models/detr/box_ops.py +103 -0
- rslearn/models/detr/detr.py +504 -0
- rslearn/models/detr/matcher.py +107 -0
- rslearn/models/detr/position_encoding.py +114 -0
- rslearn/models/detr/transformer.py +429 -0
- rslearn/models/detr/util.py +24 -0
- rslearn/models/dinov3.py +177 -0
- rslearn/models/faster_rcnn.py +30 -28
- rslearn/models/feature_center_crop.py +53 -0
- rslearn/models/fpn.py +19 -8
- rslearn/models/galileo/__init__.py +5 -0
- rslearn/models/galileo/galileo.py +595 -0
- rslearn/models/galileo/single_file_galileo.py +1678 -0
- rslearn/models/module_wrapper.py +65 -0
- rslearn/models/molmo.py +69 -0
- rslearn/models/multitask.py +384 -28
- rslearn/models/olmoearth_pretrain/__init__.py +1 -0
- rslearn/models/olmoearth_pretrain/model.py +421 -0
- rslearn/models/olmoearth_pretrain/norm.py +86 -0
- rslearn/models/panopticon.py +170 -0
- rslearn/models/panopticon_data/sensors/drone.yaml +32 -0
- rslearn/models/panopticon_data/sensors/enmap.yaml +904 -0
- rslearn/models/panopticon_data/sensors/goes.yaml +9 -0
- rslearn/models/panopticon_data/sensors/himawari.yaml +9 -0
- rslearn/models/panopticon_data/sensors/intuition.yaml +606 -0
- rslearn/models/panopticon_data/sensors/landsat8.yaml +84 -0
- rslearn/models/panopticon_data/sensors/modis_terra.yaml +99 -0
- rslearn/models/panopticon_data/sensors/qb2_ge1.yaml +34 -0
- rslearn/models/panopticon_data/sensors/sentinel1.yaml +85 -0
- rslearn/models/panopticon_data/sensors/sentinel2.yaml +97 -0
- rslearn/models/panopticon_data/sensors/superdove.yaml +60 -0
- rslearn/models/panopticon_data/sensors/wv23.yaml +63 -0
- rslearn/models/pick_features.py +17 -10
- rslearn/models/pooling_decoder.py +60 -7
- rslearn/models/presto/__init__.py +5 -0
- rslearn/models/presto/presto.py +297 -0
- rslearn/models/presto/single_file_presto.py +926 -0
- rslearn/models/prithvi.py +1147 -0
- rslearn/models/resize_features.py +59 -0
- rslearn/models/sam2_enc.py +13 -9
- rslearn/models/satlaspretrain.py +38 -18
- rslearn/models/simple_time_series.py +188 -77
- rslearn/models/singletask.py +24 -13
- rslearn/models/ssl4eo_s12.py +40 -30
- rslearn/models/swin.py +44 -32
- rslearn/models/task_embedding.py +250 -0
- rslearn/models/terramind.py +256 -0
- rslearn/models/trunk.py +139 -0
- rslearn/models/unet.py +68 -22
- rslearn/models/upsample.py +48 -0
- rslearn/models/use_croma.py +508 -0
- rslearn/template_params.py +26 -0
- rslearn/tile_stores/__init__.py +41 -18
- rslearn/tile_stores/default.py +409 -0
- rslearn/tile_stores/tile_store.py +236 -132
- rslearn/train/all_patches_dataset.py +530 -0
- rslearn/train/callbacks/adapters.py +53 -0
- rslearn/train/callbacks/freeze_unfreeze.py +348 -17
- rslearn/train/callbacks/gradients.py +129 -0
- rslearn/train/callbacks/peft.py +116 -0
- rslearn/train/data_module.py +444 -20
- rslearn/train/dataset.py +588 -235
- rslearn/train/lightning_module.py +192 -62
- rslearn/train/model_context.py +88 -0
- rslearn/train/optimizer.py +31 -0
- rslearn/train/prediction_writer.py +319 -84
- rslearn/train/scheduler.py +92 -0
- rslearn/train/tasks/classification.py +55 -28
- rslearn/train/tasks/detection.py +132 -76
- rslearn/train/tasks/embedding.py +120 -0
- rslearn/train/tasks/multi_task.py +28 -14
- rslearn/train/tasks/per_pixel_regression.py +291 -0
- rslearn/train/tasks/regression.py +161 -44
- rslearn/train/tasks/segmentation.py +428 -53
- rslearn/train/tasks/task.py +6 -5
- rslearn/train/transforms/__init__.py +1 -1
- rslearn/train/transforms/concatenate.py +54 -10
- rslearn/train/transforms/crop.py +29 -11
- rslearn/train/transforms/flip.py +18 -6
- rslearn/train/transforms/mask.py +78 -0
- rslearn/train/transforms/normalize.py +101 -17
- rslearn/train/transforms/pad.py +19 -7
- rslearn/train/transforms/resize.py +83 -0
- rslearn/train/transforms/select_bands.py +76 -0
- rslearn/train/transforms/sentinel1.py +75 -0
- rslearn/train/transforms/transform.py +89 -70
- rslearn/utils/__init__.py +2 -6
- rslearn/utils/array.py +8 -6
- rslearn/utils/feature.py +2 -2
- rslearn/utils/fsspec.py +90 -1
- rslearn/utils/geometry.py +347 -7
- rslearn/utils/get_utm_ups_crs.py +2 -3
- rslearn/utils/grid_index.py +5 -5
- rslearn/utils/jsonargparse.py +178 -0
- rslearn/utils/mp.py +4 -3
- rslearn/utils/raster_format.py +268 -116
- rslearn/utils/rtree_index.py +64 -17
- rslearn/utils/sqlite_index.py +7 -1
- rslearn/utils/vector_format.py +252 -97
- {rslearn-0.0.1.dist-info → rslearn-0.0.21.dist-info}/METADATA +532 -283
- rslearn-0.0.21.dist-info/RECORD +167 -0
- {rslearn-0.0.1.dist-info → rslearn-0.0.21.dist-info}/WHEEL +1 -1
- rslearn-0.0.21.dist-info/licenses/NOTICE +115 -0
- rslearn/data_sources/raster_source.py +0 -309
- rslearn/models/registry.py +0 -5
- rslearn/tile_stores/file.py +0 -242
- rslearn/utils/mgrs.py +0 -24
- rslearn/utils/utils.py +0 -22
- rslearn-0.0.1.dist-info/RECORD +0 -88
- /rslearn/{data_sources/geotiff.py → py.typed} +0 -0
- {rslearn-0.0.1.dist-info → rslearn-0.0.21.dist-info}/entry_points.txt +0 -0
- {rslearn-0.0.1.dist-info → rslearn-0.0.21.dist-info/licenses}/LICENSE +0 -0
- {rslearn-0.0.1.dist-info → rslearn-0.0.21.dist-info}/top_level.txt +0 -0
|
@@ -1,224 +1,328 @@
|
|
|
1
1
|
"""Base class for tile stores."""
|
|
2
2
|
|
|
3
|
-
from datetime import datetime
|
|
4
3
|
from typing import Any
|
|
5
4
|
|
|
6
5
|
import numpy.typing as npt
|
|
6
|
+
from rasterio.enums import Resampling
|
|
7
|
+
from upath import UPath
|
|
7
8
|
|
|
8
|
-
from rslearn.config import LayerConfig
|
|
9
9
|
from rslearn.utils import Feature, PixelBounds, Projection
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
class
|
|
13
|
-
"""
|
|
12
|
+
class TileStore:
|
|
13
|
+
"""An abstract class for a tile store.
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
projection: Projection,
|
|
18
|
-
time_range: tuple[datetime, datetime] | None,
|
|
19
|
-
properties: dict[str, Any],
|
|
20
|
-
) -> None:
|
|
21
|
-
"""Create a new LayerMetadata instance."""
|
|
22
|
-
self.projection = projection
|
|
23
|
-
self.time_range = time_range
|
|
24
|
-
self.properties = properties
|
|
25
|
-
|
|
26
|
-
def serialize(self) -> dict:
|
|
27
|
-
"""Serializes the metadata to a JSON-encodable dictionary."""
|
|
28
|
-
return {
|
|
29
|
-
"projection": self.projection.serialize(),
|
|
30
|
-
"time_range": (
|
|
31
|
-
[self.time_range[0].isoformat(), self.time_range[1].isoformat()]
|
|
32
|
-
if self.time_range
|
|
33
|
-
else None
|
|
34
|
-
),
|
|
35
|
-
"properties": self.properties,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@staticmethod
|
|
39
|
-
def deserialize(d: dict) -> "LayerMetadata":
|
|
40
|
-
"""Deserializes metadata from a JSON-decoded dictionary."""
|
|
41
|
-
return LayerMetadata(
|
|
42
|
-
projection=Projection.deserialize(d["projection"]),
|
|
43
|
-
time_range=(
|
|
44
|
-
(
|
|
45
|
-
datetime.fromisoformat(d["time_range"][0]),
|
|
46
|
-
datetime.fromisoformat(d["time_range"][1]),
|
|
47
|
-
)
|
|
48
|
-
if d["time_range"]
|
|
49
|
-
else None
|
|
50
|
-
),
|
|
51
|
-
properties=d["properties"],
|
|
52
|
-
)
|
|
15
|
+
A tile store supports operations to read and write raster and vector data.
|
|
16
|
+
"""
|
|
53
17
|
|
|
18
|
+
def set_dataset_path(self, ds_path: UPath) -> None:
|
|
19
|
+
"""Set the dataset path.
|
|
54
20
|
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
This is in case the TileStore wants to use the ds_path to help determine where
|
|
22
|
+
to store data.
|
|
57
23
|
|
|
58
|
-
|
|
59
|
-
|
|
24
|
+
Args:
|
|
25
|
+
ds_path: the dataset path that this TileStore is a part of.
|
|
26
|
+
"""
|
|
27
|
+
pass
|
|
60
28
|
|
|
61
|
-
def
|
|
62
|
-
|
|
29
|
+
def is_raster_ready(
|
|
30
|
+
self, layer_name: str, item_name: str, bands: list[str]
|
|
31
|
+
) -> bool:
|
|
32
|
+
"""Checks if this raster has been written to the store.
|
|
63
33
|
|
|
64
34
|
Args:
|
|
65
|
-
|
|
35
|
+
layer_name: the layer name or alias.
|
|
36
|
+
item_name: the item.
|
|
37
|
+
bands: the list of bands identifying which specific raster to read.
|
|
66
38
|
|
|
67
39
|
Returns:
|
|
68
|
-
|
|
40
|
+
whether there is a raster in the store matching the source, item, and
|
|
41
|
+
bands.
|
|
69
42
|
"""
|
|
70
43
|
raise NotImplementedError
|
|
71
44
|
|
|
72
|
-
def
|
|
73
|
-
"""
|
|
45
|
+
def get_raster_bands(self, layer_name: str, item_name: str) -> list[list[str]]:
|
|
46
|
+
"""Get the sets of bands that have been stored for the specified item.
|
|
74
47
|
|
|
75
48
|
Args:
|
|
76
|
-
|
|
77
|
-
|
|
49
|
+
layer_name: the layer name or alias.
|
|
50
|
+
item_name: the item.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
a list of lists of bands that are in the tile store (with one raster
|
|
54
|
+
stored corresponding to each inner list). If no rasters are ready for
|
|
55
|
+
this item, returns empty list.
|
|
78
56
|
"""
|
|
79
57
|
raise NotImplementedError
|
|
80
58
|
|
|
81
|
-
def
|
|
82
|
-
|
|
59
|
+
def get_raster_bounds(
|
|
60
|
+
self, layer_name: str, item_name: str, bands: list[str], projection: Projection
|
|
61
|
+
) -> PixelBounds:
|
|
62
|
+
"""Get the bounds of the raster in the specified projection.
|
|
83
63
|
|
|
84
64
|
Args:
|
|
85
|
-
|
|
65
|
+
layer_name: the layer name or alias.
|
|
66
|
+
item_name: the item to check.
|
|
67
|
+
bands: the list of bands identifying which specific raster to read. These
|
|
68
|
+
bands must match the bands of a stored raster.
|
|
69
|
+
projection: the projection to get the raster's bounds in.
|
|
86
70
|
|
|
87
71
|
Returns:
|
|
88
|
-
the
|
|
72
|
+
the bounds of the raster in the projection.
|
|
89
73
|
"""
|
|
90
74
|
raise NotImplementedError
|
|
91
75
|
|
|
92
|
-
def
|
|
93
|
-
|
|
76
|
+
def read_raster(
|
|
77
|
+
self,
|
|
78
|
+
layer_name: str,
|
|
79
|
+
item_name: str,
|
|
80
|
+
bands: list[str],
|
|
81
|
+
projection: Projection,
|
|
82
|
+
bounds: PixelBounds,
|
|
83
|
+
resampling: Resampling = Resampling.bilinear,
|
|
84
|
+
) -> npt.NDArray[Any]:
|
|
85
|
+
"""Read raster data from the store.
|
|
94
86
|
|
|
95
87
|
Args:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
layer_name: the layer name or alias.
|
|
89
|
+
item_name: the item to read.
|
|
90
|
+
bands: the list of bands identifying which specific raster to read. These
|
|
91
|
+
bands must match the bands of a stored raster.
|
|
92
|
+
projection: the projection to read in.
|
|
93
|
+
bounds: the bounds to read.
|
|
94
|
+
resampling: the resampling method to use in case reprojection is needed.
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
Returns:
|
|
97
|
+
the raster data
|
|
98
|
+
"""
|
|
102
99
|
raise NotImplementedError
|
|
103
100
|
|
|
104
|
-
def
|
|
105
|
-
|
|
101
|
+
def write_raster(
|
|
102
|
+
self,
|
|
103
|
+
layer_name: str,
|
|
104
|
+
item_name: str,
|
|
105
|
+
bands: list[str],
|
|
106
|
+
projection: Projection,
|
|
107
|
+
bounds: PixelBounds,
|
|
108
|
+
array: npt.NDArray[Any],
|
|
109
|
+
) -> None:
|
|
110
|
+
"""Write raster data to the store.
|
|
106
111
|
|
|
107
112
|
Args:
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
layer_name: the layer name or alias.
|
|
114
|
+
item_name: the item to write.
|
|
115
|
+
bands: the list of bands in the array.
|
|
116
|
+
projection: the projection of the array.
|
|
117
|
+
bounds: the bounds of the array.
|
|
118
|
+
array: the raster data.
|
|
110
119
|
"""
|
|
111
120
|
raise NotImplementedError
|
|
112
121
|
|
|
122
|
+
def write_raster_file(
|
|
123
|
+
self, layer_name: str, item_name: str, bands: list[str], fname: UPath
|
|
124
|
+
) -> None:
|
|
125
|
+
"""Write raster data to the store.
|
|
113
126
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
Args:
|
|
128
|
+
layer_name: the layer name or alias.
|
|
129
|
+
item_name: the item to write.
|
|
130
|
+
bands: the list of bands in the array.
|
|
131
|
+
fname: the raster file.
|
|
132
|
+
"""
|
|
133
|
+
raise NotImplementedError
|
|
119
134
|
|
|
120
|
-
def
|
|
121
|
-
|
|
122
|
-
) -> TileStoreLayer:
|
|
123
|
-
"""Create a layer in the tile store (or get matching existing layer).
|
|
135
|
+
def is_vector_ready(self, layer_name: str, item_name: str) -> bool:
|
|
136
|
+
"""Checks if this vector item has been written to the store.
|
|
124
137
|
|
|
125
138
|
Args:
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
layer_name: the layer name or alias.
|
|
140
|
+
item_name: the item.
|
|
128
141
|
|
|
129
142
|
Returns:
|
|
130
|
-
|
|
143
|
+
whether the vector data from the item has been stored.
|
|
131
144
|
"""
|
|
132
145
|
raise NotImplementedError
|
|
133
146
|
|
|
134
|
-
def
|
|
135
|
-
|
|
147
|
+
def read_vector(
|
|
148
|
+
self,
|
|
149
|
+
layer_name: str,
|
|
150
|
+
item_name: str,
|
|
151
|
+
projection: Projection,
|
|
152
|
+
bounds: PixelBounds,
|
|
153
|
+
) -> list[Feature]:
|
|
154
|
+
"""Read vector data from the store.
|
|
136
155
|
|
|
137
156
|
Args:
|
|
138
|
-
|
|
157
|
+
layer_name: the layer name or alias.
|
|
158
|
+
item_name: the item to read.
|
|
159
|
+
projection: the projection to read in.
|
|
160
|
+
bounds: the bounds within which to read.
|
|
139
161
|
|
|
140
162
|
Returns:
|
|
141
|
-
the
|
|
163
|
+
the vector data
|
|
142
164
|
"""
|
|
143
165
|
raise NotImplementedError
|
|
144
166
|
|
|
145
|
-
def
|
|
146
|
-
|
|
167
|
+
def write_vector(
|
|
168
|
+
self, layer_name: str, item_name: str, features: list[Feature]
|
|
169
|
+
) -> None:
|
|
170
|
+
"""Write vector data to the store.
|
|
147
171
|
|
|
148
172
|
Args:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
available options for next part of the layer ID
|
|
173
|
+
layer_name: the layer name or alias.
|
|
174
|
+
item_name: the item to write.
|
|
175
|
+
features: the vector data.
|
|
153
176
|
"""
|
|
154
177
|
raise NotImplementedError
|
|
155
178
|
|
|
156
179
|
|
|
157
|
-
class
|
|
158
|
-
"""
|
|
180
|
+
class TileStoreWithLayer:
|
|
181
|
+
"""Convenience class to access TileStore in the context of a layer."""
|
|
159
182
|
|
|
160
|
-
def __init__(self, tile_store: TileStore,
|
|
161
|
-
"""
|
|
183
|
+
def __init__(self, tile_store: TileStore, layer_name: str):
|
|
184
|
+
"""Create a new TileStoreWithLayer.
|
|
162
185
|
|
|
163
186
|
Args:
|
|
164
|
-
tile_store:
|
|
165
|
-
|
|
187
|
+
tile_store: underlying TileStore.
|
|
188
|
+
layer_name: the layer name.
|
|
166
189
|
"""
|
|
167
190
|
self.tile_store = tile_store
|
|
168
|
-
self.
|
|
191
|
+
self.layer_name = layer_name
|
|
169
192
|
|
|
170
|
-
def
|
|
171
|
-
|
|
172
|
-
) -> TileStoreLayer:
|
|
173
|
-
"""Create a layer in the tile store (or get matching existing layer).
|
|
193
|
+
def is_raster_ready(self, item_name: str, bands: list[str]) -> bool:
|
|
194
|
+
"""Checks if this raster has been written to the store.
|
|
174
195
|
|
|
175
196
|
Args:
|
|
176
|
-
|
|
177
|
-
|
|
197
|
+
item_name: the item.
|
|
198
|
+
bands: the list of bands identifying which specific raster to read.
|
|
178
199
|
|
|
179
200
|
Returns:
|
|
180
|
-
a
|
|
201
|
+
whether there is a raster in the store matching the source, item, and
|
|
202
|
+
bands.
|
|
181
203
|
"""
|
|
182
|
-
return self.tile_store.
|
|
204
|
+
return self.tile_store.is_raster_ready(self.layer_name, item_name, bands)
|
|
183
205
|
|
|
184
|
-
def
|
|
185
|
-
"""Get
|
|
206
|
+
def get_raster_bands(self, item_name: str) -> list[list[str]]:
|
|
207
|
+
"""Get the sets of bands that have been stored for the specified item.
|
|
186
208
|
|
|
187
209
|
Args:
|
|
188
|
-
|
|
210
|
+
item_name: the item.
|
|
189
211
|
|
|
190
212
|
Returns:
|
|
191
|
-
|
|
213
|
+
a list of lists of bands that are in the tile store (with one raster
|
|
214
|
+
stored corresponding to each inner list). If no rasters are ready for
|
|
215
|
+
this item, returns empty list.
|
|
192
216
|
"""
|
|
193
|
-
return self.tile_store.
|
|
217
|
+
return self.tile_store.get_raster_bands(self.layer_name, item_name)
|
|
194
218
|
|
|
195
|
-
def
|
|
196
|
-
|
|
219
|
+
def get_raster_bounds(
|
|
220
|
+
self, item_name: str, bands: list[str], projection: Projection
|
|
221
|
+
) -> PixelBounds:
|
|
222
|
+
"""Get the bounds of the raster in the specified projection.
|
|
197
223
|
|
|
198
224
|
Args:
|
|
199
|
-
|
|
225
|
+
item_name: the item to check.
|
|
226
|
+
bands: the list of bands identifying which specific raster to read. These
|
|
227
|
+
bands must match the bands of a stored raster.
|
|
228
|
+
projection: the projection to get the raster's bounds in.
|
|
200
229
|
|
|
201
230
|
Returns:
|
|
202
|
-
|
|
231
|
+
the bounds of the raster in the projection.
|
|
203
232
|
"""
|
|
204
|
-
return self.tile_store.
|
|
233
|
+
return self.tile_store.get_raster_bounds(
|
|
234
|
+
self.layer_name, item_name, bands, projection
|
|
235
|
+
)
|
|
205
236
|
|
|
237
|
+
def read_raster(
|
|
238
|
+
self,
|
|
239
|
+
item_name: str,
|
|
240
|
+
bands: list[str],
|
|
241
|
+
projection: Projection,
|
|
242
|
+
bounds: PixelBounds,
|
|
243
|
+
resampling: Resampling = Resampling.bilinear,
|
|
244
|
+
) -> npt.NDArray[Any]:
|
|
245
|
+
"""Read raster data from the store.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
item_name: the item to read.
|
|
249
|
+
bands: the list of bands identifying which specific raster to read. These
|
|
250
|
+
bands must match the bands of a stored raster.
|
|
251
|
+
projection: the projection to read in.
|
|
252
|
+
bounds: the bounds to read.
|
|
253
|
+
resampling: the resampling method to use in case reprojection is needed.
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
the raster data
|
|
257
|
+
"""
|
|
258
|
+
return self.tile_store.read_raster(
|
|
259
|
+
self.layer_name, item_name, bands, projection, bounds, resampling
|
|
260
|
+
)
|
|
206
261
|
|
|
207
|
-
def
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
262
|
+
def write_raster(
|
|
263
|
+
self,
|
|
264
|
+
item_name: str,
|
|
265
|
+
bands: list[str],
|
|
266
|
+
projection: Projection,
|
|
267
|
+
bounds: PixelBounds,
|
|
268
|
+
array: npt.NDArray[Any],
|
|
269
|
+
) -> None:
|
|
270
|
+
"""Write raster data to the store.
|
|
211
271
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
272
|
+
Args:
|
|
273
|
+
item_name: the item to write.
|
|
274
|
+
bands: the list of bands in the array.
|
|
275
|
+
projection: the projection of the array.
|
|
276
|
+
bounds: the bounds of the array.
|
|
277
|
+
array: the raster data.
|
|
278
|
+
"""
|
|
279
|
+
self.tile_store.write_raster(
|
|
280
|
+
self.layer_name, item_name, bands, projection, bounds, array
|
|
281
|
+
)
|
|
216
282
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
283
|
+
def write_raster_file(self, item_name: str, bands: list[str], fname: UPath) -> None:
|
|
284
|
+
"""Write raster data to the store.
|
|
285
|
+
|
|
286
|
+
Args:
|
|
287
|
+
item_name: the item to write.
|
|
288
|
+
bands: the list of bands in the array.
|
|
289
|
+
fname: the raster file.
|
|
290
|
+
"""
|
|
291
|
+
self.tile_store.write_raster_file(self.layer_name, item_name, bands, fname)
|
|
292
|
+
|
|
293
|
+
def is_vector_ready(self, item_name: str) -> bool:
|
|
294
|
+
"""Checks if this vector item has been written to the store.
|
|
295
|
+
|
|
296
|
+
Args:
|
|
297
|
+
item_name: the item.
|
|
298
|
+
|
|
299
|
+
Returns:
|
|
300
|
+
whether the vector data from the item has been stored.
|
|
301
|
+
"""
|
|
302
|
+
return self.tile_store.is_vector_ready(self.layer_name, item_name)
|
|
303
|
+
|
|
304
|
+
def read_vector(
|
|
305
|
+
self, item_name: str, projection: Projection, bounds: PixelBounds
|
|
306
|
+
) -> list[Feature]:
|
|
307
|
+
"""Read vector data from the store.
|
|
308
|
+
|
|
309
|
+
Args:
|
|
310
|
+
item_name: the item to read.
|
|
311
|
+
projection: the projection to read in.
|
|
312
|
+
bounds: the bounds within which to read.
|
|
313
|
+
|
|
314
|
+
Returns:
|
|
315
|
+
the vector data
|
|
316
|
+
"""
|
|
317
|
+
return self.tile_store.read_vector(
|
|
318
|
+
self.layer_name, item_name, projection, bounds
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
def write_vector(self, item_name: str, features: list[Feature]) -> None:
|
|
322
|
+
"""Write vector data to the store.
|
|
323
|
+
|
|
324
|
+
Args:
|
|
325
|
+
item_name: the item to write.
|
|
326
|
+
features: the vector data.
|
|
327
|
+
"""
|
|
328
|
+
self.tile_store.write_vector(self.layer_name, item_name, features)
|