-
Notifications
You must be signed in to change notification settings - Fork 1
/
example_convert.py
57 lines (52 loc) · 2.06 KB
/
example_convert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Author: Georg Zitzlsberger (georg.zitzlsberger<ad>vsb.cz)
# Copyright (C) 2020-2022 Georg Zitzlsberger, IT4Innovations,
# VSB-Technical University of Ostrava, Czech Republic
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
import os
import sys
sys.path.append("../lib/")
import rsdtlib
# Just a small area in Ostrava/CZ
my_aoi = "./ostrava.shp"
# Locations where to store the EOPatches
dst_path = "./obs/LS5/"
if not os.path.isdir(dst_path):
os.makedirs(dst_path, exist_ok=True)
# Convert observations (as GeoTIFF files) to EOPatches to be stored in
# 'dst_path' and restricted to AoI 'my_aoi'.
# Note: This does not yet start processing!
convert = rsdtlib.Convert(
dst_path=dst_path,
aoi=my_aoi)
# Example of converting one GeoTIFF pair (one file with all bands, and one with
# mask).
sample = convert.process(
root_path="./LS5/",
bands_tiff="19931010T090051.TIF", # LS5 TM 7 bands
mask_tiff="19931010T090051_QA.TIF", # LS5 TM QA band
timestamp="19931010T090051")
# Shows the EOPatch:
# EOPatch(
# data={
# Bands: numpy.ndarray(shape=(1, 46, 87, 7), dtype=float32)
# }
# mask={
# Mask: numpy.ndarray(shape=(1, 46, 87, 1), dtype=uint16)
# }
# bbox=BBox(((18.14081078, 49.83455151),
# (18.17269592, 49.85132019)), crs=CRS('4326'))
# timestamp=[datetime.datetime(1993, 10, 10, 9, 0, 51)]
# )
print(sample)