Commit 9969933d authored by Hannes Diedrich's avatar Hannes Diedrich
Browse files

Added nodata value to tif files.

parent 9966be0c
Pipeline #2709 passed with stages
in 19 minutes and 29 seconds
......@@ -416,7 +416,7 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
img.SetGeoTransform(geotrans)
img.SetProjection(geo_proj)
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("Central Wavelength", wl[str(band)])
img.GetRasterBand(1).SetMetadataItem("Acknowledgement",
......@@ -439,9 +439,11 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
img.SetGeoTransform(geotrans)
img.SetProjection(geo_proj)
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("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",
"The 'GFZ Time Series System for Sentinel-2' "
"(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
slice = 1
for zi in bands.split("_"):
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("Central Wavelength", wl[str(zi)])
img.GetRasterBand(slice).SetMetadataItem("Acknowledgement",
......@@ -527,6 +528,8 @@ def json_to_tiff(out_mode, api_result, only_tile, outpath, out_prefix, wl, level
"2017/12.")
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,
'TIFFTAG_XRESOLUTION': '%s' % stack_resolution})
......@@ -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_arr = np.asarray(clm)
img.GetRasterBand(slice).WriteArray(clm_arr)
img.GetRasterBand(slice).SetNoDataValue(-9999)
img.GetRasterBand(slice).SetMetadataItem("Name", "MSK")
img.GetRasterBand(slice).SetMetadataItem("MSK_legend", str(api_result['Metadata']['MSK_legend']))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment