kuva-reader 1.1.2__py3-none-any.whl → 1.1.3__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.
Potentially problematic release.
This version of kuva-reader might be problematic. Click here for more details.
- kuva_reader/reader/level0.py +1 -0
- kuva_reader/reader/level1.py +52 -2
- kuva_reader/reader/level2.py +37 -5
- {kuva_reader-1.1.2.dist-info → kuva_reader-1.1.3.dist-info}/METADATA +1 -1
- {kuva_reader-1.1.2.dist-info → kuva_reader-1.1.3.dist-info}/RECORD +7 -7
- {kuva_reader-1.1.2.dist-info → kuva_reader-1.1.3.dist-info}/WHEEL +0 -0
- {kuva_reader-1.1.2.dist-info → kuva_reader-1.1.3.dist-info}/entry_points.txt +0 -0
kuva_reader/reader/level0.py
CHANGED
kuva_reader/reader/level1.py
CHANGED
|
@@ -52,7 +52,7 @@ class Level1ABProduct(ProductBase[MetadataLevel1AB]):
|
|
|
52
52
|
|
|
53
53
|
self._image = cast(
|
|
54
54
|
rio.DatasetReader,
|
|
55
|
-
rio.open(self.image_path / "L1B.tif"),
|
|
55
|
+
rio.open(self.image_path / "L1B.tif", num_threads='16'),
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
self.data_tags = self.image.tags()
|
|
@@ -141,6 +141,31 @@ class Level1ABProduct(ProductBase[MetadataLevel1AB]):
|
|
|
141
141
|
del self._image
|
|
142
142
|
self._image = None
|
|
143
143
|
|
|
144
|
+
def generate_metadata_file(self) -> None:
|
|
145
|
+
"""Write the sidecar files next to the product."""
|
|
146
|
+
metadata_file_name = self.image_path.name + ".json"
|
|
147
|
+
|
|
148
|
+
with rio.open(self.image_path / "L1B.tif") as src:
|
|
149
|
+
shape = (src.height, src.width)
|
|
150
|
+
crs_epsg = src.crs.to_epsg()
|
|
151
|
+
geotransform = src.transform
|
|
152
|
+
gsd_w, gsd_h = src.res
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
with (self.image_path / metadata_file_name).open("w") as fh:
|
|
156
|
+
fh.write(
|
|
157
|
+
self.metadata.model_dump_json(
|
|
158
|
+
indent=2,
|
|
159
|
+
context={
|
|
160
|
+
"shape": shape,
|
|
161
|
+
"epsg": crs_epsg,
|
|
162
|
+
"transform": geotransform,
|
|
163
|
+
"gsd_w": gsd_w,
|
|
164
|
+
"gsd_h": gsd_h,
|
|
165
|
+
},
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
|
|
144
169
|
|
|
145
170
|
class Level1CProduct(ProductBase[MetadataLevel1C]):
|
|
146
171
|
"""
|
|
@@ -180,7 +205,7 @@ class Level1CProduct(ProductBase[MetadataLevel1C]):
|
|
|
180
205
|
|
|
181
206
|
self._image = cast(
|
|
182
207
|
rio.DatasetReader,
|
|
183
|
-
rio.open(self.image_path / "L1C.tif"),
|
|
208
|
+
rio.open(self.image_path / "L1C.tif", num_threads='16'),
|
|
184
209
|
)
|
|
185
210
|
self.data_tags = self.image.tags()
|
|
186
211
|
|
|
@@ -250,6 +275,31 @@ class Level1CProduct(ProductBase[MetadataLevel1C]):
|
|
|
250
275
|
del self._image
|
|
251
276
|
self._image = None
|
|
252
277
|
|
|
278
|
+
def generate_metadata_file(self) -> None:
|
|
279
|
+
"""Write the sidecar files next to the product."""
|
|
280
|
+
metadata_file_name = self.image_path.name + ".json"
|
|
281
|
+
|
|
282
|
+
with rio.open(self.image_path / "L1C.tif") as src:
|
|
283
|
+
shape = (src.height, src.width)
|
|
284
|
+
crs_epsg = src.crs.to_epsg()
|
|
285
|
+
geotransform = src.transform
|
|
286
|
+
gsd_w, gsd_h = src.res
|
|
287
|
+
|
|
288
|
+
|
|
289
|
+
with (self.image_path / metadata_file_name).open("w") as fh:
|
|
290
|
+
fh.write(
|
|
291
|
+
self.metadata.model_dump_json(
|
|
292
|
+
indent=2,
|
|
293
|
+
context={
|
|
294
|
+
"shape": shape,
|
|
295
|
+
"epsg": crs_epsg,
|
|
296
|
+
"transform": geotransform,
|
|
297
|
+
"gsd_w": gsd_w,
|
|
298
|
+
"gsd_h": gsd_h,
|
|
299
|
+
},
|
|
300
|
+
)
|
|
301
|
+
)
|
|
302
|
+
|
|
253
303
|
|
|
254
304
|
def generate_level_1_metafile():
|
|
255
305
|
"""Example function for reading a product and generating a metadata file from the
|
kuva_reader/reader/level2.py
CHANGED
|
@@ -47,9 +47,9 @@ class Level2AProduct(ProductBase[MetadataLevel2A]):
|
|
|
47
47
|
) -> None:
|
|
48
48
|
super().__init__(image_path, metadata, target_ureg)
|
|
49
49
|
|
|
50
|
-
self.
|
|
50
|
+
self._image = cast(
|
|
51
51
|
rio.DatasetReader,
|
|
52
|
-
rio.open(self.image_path / "L2A.tif"),
|
|
52
|
+
rio.open(self.image_path / "L2A.tif", num_threads='16'),
|
|
53
53
|
)
|
|
54
54
|
self.data_tags = self.image.tags()
|
|
55
55
|
|
|
@@ -70,6 +70,12 @@ class Level2AProduct(ProductBase[MetadataLevel2A]):
|
|
|
70
70
|
else:
|
|
71
71
|
return f"{self.__class__.__name__} loaded from '{self.image_path}'"
|
|
72
72
|
|
|
73
|
+
@property
|
|
74
|
+
def image(self) -> rio.DatasetReader:
|
|
75
|
+
if self._image is None:
|
|
76
|
+
raise RuntimeError("Images has been released.")
|
|
77
|
+
return self._image
|
|
78
|
+
|
|
73
79
|
def footprint(self, crs="") -> Polygon:
|
|
74
80
|
"""The product footprint as a Shapely polygon."""
|
|
75
81
|
return image_footprint(self.image, crs)
|
|
@@ -108,9 +114,35 @@ class Level2AProduct(ProductBase[MetadataLevel2A]):
|
|
|
108
114
|
"""Explicitely closes the Rasterio DatasetReader and releases the memory of
|
|
109
115
|
the `image` variable.
|
|
110
116
|
"""
|
|
111
|
-
self.
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
if self._image is not None:
|
|
118
|
+
self._image.close()
|
|
119
|
+
del self._image
|
|
120
|
+
self._image = None
|
|
121
|
+
|
|
122
|
+
def generate_metadata_file(self) -> None:
|
|
123
|
+
"""Write the sidecar files next to the product."""
|
|
124
|
+
metadata_file_name = self.image_path.name + ".json"
|
|
125
|
+
|
|
126
|
+
with rio.open(self.image_path / "L2A.tif") as src:
|
|
127
|
+
shape = (src.height, src.width)
|
|
128
|
+
crs_epsg = src.crs.to_epsg()
|
|
129
|
+
geotransform = src.transform
|
|
130
|
+
gsd_w, gsd_h = src.res
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
with (self.image_path / metadata_file_name).open("w") as fh:
|
|
134
|
+
fh.write(
|
|
135
|
+
self.metadata.model_dump_json(
|
|
136
|
+
indent=2,
|
|
137
|
+
context={
|
|
138
|
+
"shape": shape,
|
|
139
|
+
"epsg": crs_epsg,
|
|
140
|
+
"transform": geotransform,
|
|
141
|
+
"gsd_w": gsd_w,
|
|
142
|
+
"gsd_h": gsd_h,
|
|
143
|
+
},
|
|
144
|
+
)
|
|
145
|
+
)
|
|
114
146
|
|
|
115
147
|
|
|
116
148
|
def generate_level_2_metafile():
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: kuva-reader
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.3
|
|
4
4
|
Summary: Manipulate the Kuva Space image and metadata formats
|
|
5
5
|
Author-email: Guillem Ballesteros <guillem@kuvaspace.com>, Lennert Antson <lennert.antson@kuvaspace.com>, Arthur Vandenhoeke <arthur.vandenhoeke@kuvaspace.com>, Olli Eloranta <olli.eloranta@kuvaspace.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -2,14 +2,14 @@ kuva_reader/__init__.py,sha256=7OSXrTPW3RTjctJZqyGTekuHRb_5aQNJaG_c-KFac_s,1389
|
|
|
2
2
|
kuva_reader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
kuva_reader/reader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
kuva_reader/reader/image.py,sha256=rqzs5C7nzRArFfVepydRUECd3u55McTZlKINg76nMX4,785
|
|
5
|
-
kuva_reader/reader/level0.py,sha256=
|
|
6
|
-
kuva_reader/reader/level1.py,sha256=
|
|
7
|
-
kuva_reader/reader/level2.py,sha256=
|
|
5
|
+
kuva_reader/reader/level0.py,sha256=Dvf3I8Vv4UIFMd5DgR8JZx51zhjx4aKbt64TGYqXxk4,9761
|
|
6
|
+
kuva_reader/reader/level1.py,sha256=tTQBqzXK1Wna2s866gjHzsYKwJ0evAhaoKFXk0jHPBo,10584
|
|
7
|
+
kuva_reader/reader/level2.py,sha256=3SiD1lEPNi4mG7yR2omY9YkrPFbv-nxGFViuN2pig6U,5207
|
|
8
8
|
kuva_reader/reader/product_base.py,sha256=OuV69tm53j6terSWb7ViXDYkGeK5mWwcbfwIVuZqVg4,4296
|
|
9
9
|
kuva_reader/reader/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
kuva_reader/reader/read.py,sha256=b5hGFbeJ-7sg-iilSJn29Hcqj4e7kiWT2S0BH2JwcDE,1761
|
|
11
11
|
kuva_reader/reader/utils.py,sha256=oZ1G43nm8lCxzfbdqBs0KhKaXWe_uf-78uBXWvmZigs,1566
|
|
12
|
-
kuva_reader-1.1.
|
|
13
|
-
kuva_reader-1.1.
|
|
14
|
-
kuva_reader-1.1.
|
|
15
|
-
kuva_reader-1.1.
|
|
12
|
+
kuva_reader-1.1.3.dist-info/METADATA,sha256=pDBBjplO1sTSq-_HOs-WQwjmPyUgb5Z-bX47XmbU-kk,4902
|
|
13
|
+
kuva_reader-1.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
14
|
+
kuva_reader-1.1.3.dist-info/entry_points.txt,sha256=KB_U0ziK5k7o8en_7lMtx3Jb1LRHhp39Wpt5MWbZuB0,152
|
|
15
|
+
kuva_reader-1.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|