Skip to content
GitLab
Menu
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
9fe603f2
Commit
9fe603f2
authored
Mar 01, 2018
by
Hannes Diedrich
Browse files
Merge branch 'bugfix/add_ndv_to_tifs' into 'master'
Added nodata value to tif files. See merge request
!9
parents
9966be0c
9969933d
Pipeline
#2710
passed with stages
in 17 minutes and 50 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
gts2_client/gts2_client.py
View file @
9fe603f2
...
@@ -416,7 +416,7 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
...
@@ -416,7 +416,7 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
img
.
SetGeoTransform
(
geotrans
)
img
.
SetGeoTransform
(
geotrans
)
img
.
SetProjection
(
geo_proj
)
img
.
SetProjection
(
geo_proj
)
img
.
GetRasterBand
(
1
).
WriteArray
(
arr
)
img
.
GetRasterBand
(
1
).
WriteArray
(
arr
)
img
.
GetRasterBand
(
1
).
SetNoDataValue
(
-
9999
)
img
.
GetRasterBand
(
1
).
SetNoDataValue
(
api_result
[
'Results'
][
tile_key
][
band_key
][
"fill_value"
]
)
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Name"
,
"Band"
+
str
(
band
)[
1
:
3
])
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Name"
,
"Band"
+
str
(
band
)[
1
:
3
])
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Central Wavelength"
,
wl
[
str
(
band
)])
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Central Wavelength"
,
wl
[
str
(
band
)])
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Acknowledgement"
,
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Acknowledgement"
,
...
@@ -439,9 +439,11 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
...
@@ -439,9 +439,11 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
img
.
SetGeoTransform
(
geotrans
)
img
.
SetGeoTransform
(
geotrans
)
img
.
SetProjection
(
geo_proj
)
img
.
SetProjection
(
geo_proj
)
img
.
GetRasterBand
(
1
).
WriteArray
(
clm_arr
)
img
.
GetRasterBand
(
1
).
WriteArray
(
clm_arr
)
img
.
GetRasterBand
(
1
).
SetNoDataValue
(
-
9999
)
img
.
GetRasterBand
(
1
).
SetNoDataValue
(
api_result
[
'Results'
][
tile_key
][
band_key
]
[
"fill_value"
])
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Name"
,
"MSK"
)
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Name"
,
"MSK"
)
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"MSK_legend"
,
str
(
api_result
[
'Metadata'
][
'MSK_legend'
]))
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"MSK_legend"
,
str
(
api_result
[
'Metadata'
]
[
'MSK_legend'
]))
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Acknowledgement"
,
img
.
GetRasterBand
(
1
).
SetMetadataItem
(
"Acknowledgement"
,
"The 'GFZ Time Series System for Sentinel-2' "
"The 'GFZ Time Series System for Sentinel-2' "
"(GTS2) was financed by AgriCircle/ADAMA between "
"(GTS2) was financed by AgriCircle/ADAMA between "
...
@@ -518,7 +520,6 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
...
@@ -518,7 +520,6 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
slice
=
1
slice
=
1
for
zi
in
bands
.
split
(
"_"
):
for
zi
in
bands
.
split
(
"_"
):
img
.
GetRasterBand
(
slice
).
WriteArray
(
zm_dict
[
zi
])
img
.
GetRasterBand
(
slice
).
WriteArray
(
zm_dict
[
zi
])
img
.
GetRasterBand
(
slice
).
SetNoDataValue
(
-
9999
)
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Name"
,
"Band"
+
zi
[
1
:
3
])
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Name"
,
"Band"
+
zi
[
1
:
3
])
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Central Wavelength"
,
wl
[
str
(
zi
)])
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Central Wavelength"
,
wl
[
str
(
zi
)])
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Acknowledgement"
,
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Acknowledgement"
,
...
@@ -527,6 +528,8 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
...
@@ -527,6 +528,8 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
"2017/12."
)
"2017/12."
)
slice
+=
1
slice
+=
1
# This is done outside of the loop because one can not set a nodata_value for each band
img
.
GetRasterBand
(
slice
).
SetNoDataValue
(
api_result
[
'Results'
][
tile_key
][
band_key
][
"fill_value"
])
img
.
SetMetadata
({
'TIFFTAG_YRESOLUTION'
:
'%s'
%
stack_resolution
,
img
.
SetMetadata
({
'TIFFTAG_YRESOLUTION'
:
'%s'
%
stack_resolution
,
'TIFFTAG_XRESOLUTION'
:
'%s'
%
stack_resolution
})
'TIFFTAG_XRESOLUTION'
:
'%s'
%
stack_resolution
})
...
@@ -534,7 +537,6 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
...
@@ -534,7 +537,6 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
clm
=
api_result
[
'Metadata'
][
tile_key
][
'MSK_%sm'
%
stack_resolution
][
'data'
][
ti
]
clm
=
api_result
[
'Metadata'
][
tile_key
][
'MSK_%sm'
%
stack_resolution
][
'data'
][
ti
]
clm_arr
=
np
.
asarray
(
clm
)
clm_arr
=
np
.
asarray
(
clm
)
img
.
GetRasterBand
(
slice
).
WriteArray
(
clm_arr
)
img
.
GetRasterBand
(
slice
).
WriteArray
(
clm_arr
)
img
.
GetRasterBand
(
slice
).
SetNoDataValue
(
-
9999
)
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Name"
,
"MSK"
)
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"Name"
,
"MSK"
)
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"MSK_legend"
,
str
(
api_result
[
'Metadata'
][
'MSK_legend'
]))
img
.
GetRasterBand
(
slice
).
SetMetadataItem
(
"MSK_legend"
,
str
(
api_result
[
'Metadata'
][
'MSK_legend'
]))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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