Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gts2
gts2_client
Commits
9fd7973d
Commit
9fd7973d
authored
Jan 04, 2021
by
tsanona
Browse files
add compression option to client
parent
d4d4381b
Pipeline
#17505
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gts2_client/gts2_client.py
View file @
9fd7973d
...
...
@@ -397,7 +397,8 @@ def mk_rgb(basedir, outdir, rgb_comb=("B04", "B03", "B02"), rgb_gamma=(1.0, 1.0,
return
fnout_list
def
json_to_tiff
(
out_mode
,
api_result
,
only_tile
,
outpath
,
out_prefix
,
wl
,
level
,
stack_resolution
,
bands
,
logger
=
None
):
def
json_to_tiff
(
out_mode
,
api_result
,
only_tile
,
outpath
,
out_prefix
,
wl
,
level
,
stack_resolution
,
bands
,
tif_opts
,
logger
=
None
):
"""
Get data from json dict and save if as singletif files OR:
save all requested bands plus cloudmask as one tiff file per date and tile.
...
...
@@ -410,6 +411,7 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
:type level: string
:type stack_resolution: string
:type bands: string
:type tif_opts: list of string
:type logger: logger
:return: List of written tifs (list of strings)
"""
...
...
@@ -445,7 +447,7 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
outfile
=
"{path}/{sensor}_{level}_{pref}_{date}_{tile}_{band}_{res}m.tif"
.
format
(
path
=
outpath
,
pref
=
out_prefix
,
date
=
ac_date
,
tile
=
tile_key
,
band
=
band
,
level
=
level
,
res
=
res
,
sensor
=
sensor
)
img
=
driver
.
Create
(
outfile
,
cols
,
rows
,
1
,
gdal
.
GDT_Int32
)
img
=
driver
.
Create
(
outfile
,
cols
,
rows
,
1
,
gdal
.
GDT_Int32
,
options
=
tif_opts
)
img
.
SetGeoTransform
(
geotrans
)
img
.
SetProjection
(
geo_proj
)
img
.
GetRasterBand
(
1
).
WriteArray
(
arr
)
...
...
@@ -741,7 +743,7 @@ def __get_auth(logger=None):
return
{
"auth"
:
auth
,
"port"
:
port
}
def
client
(
outpath
=
""
,
out_prefix
=
""
,
out_mode
=
"json"
,
geo_ll
=
(),
geo_ur
=
(),
sensor
=
"S2A"
,
bands
=
""
,
max_cloudy
=
"0.5"
,
def
client
(
outpath
=
""
,
out_prefix
=
""
,
out_mode
=
"json"
,
compress
=
"ZSTD-2"
,
geo_ll
=
(),
geo_ur
=
(),
sensor
=
"S2A"
,
bands
=
""
,
max_cloudy
=
"0.5"
,
level
=
"L2A"
,
start_date
=
""
,
end_date
=
""
,
version
=
"0.15"
,
suffix
=
""
,
minimum_fill
=
"0.8"
,
only_tile
=
""
,
stack_resolution
=
"10"
,
quiet
=
False
,
rgb_extension
=
"jpg"
,
rgb_bands_selection
=
"realistic"
,
merge_tifs
=
False
,
merge_tile
=
None
,
onlytime
=
False
,
timeout
=
None
):
...
...
@@ -758,6 +760,7 @@ def client(outpath="", out_prefix="", out_mode="json", geo_ll=(), geo_ur=(), sen
:type outpath: string
:type out_prefix: string
:type out_mode: string
:type compress: string
:type geo_ll: tuple of floats
:type geo_ur: tuple of floats
:type sensor: string
...
...
@@ -859,8 +862,10 @@ def client(outpath="", out_prefix="", out_mode="json", geo_ll=(), geo_ur=(), sen
elif
out_mode
==
"single"
or
out_mode
==
"stack"
:
logger
.
info
(
"Converting data to %s tif-files ..."
%
out_mode
,
)
if
compress
:
tif_opts
=
"COMPRESS={}_PREDICTOR={}"
.
format
(
*
compress
.
split
(
"-"
)).
split
(
"_"
)
tif_list
=
json_to_tiff
(
out_mode
,
api_result
,
only_tile
,
outpath
,
out_prefix
,
wl
,
level
,
stack_resolution
,
bands
,
logger
=
logger
)
bands
,
tif_opts
=
tif_opts
,
logger
=
logger
)
if
merge_tifs
is
True
:
merge_tiles
(
tif_list
,
out_mode
=
out_mode
,
target_tile
=
merge_tile
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment