From 5ddc43b98f3f26dc229f72ae95bcc18d8472847f Mon Sep 17 00:00:00 2001 From: Yu Morishita Date: Tue, 9 Feb 2021 17:03:32 +0900 Subject: [PATCH] Small update about nodata --- LiCSBAS_lib/LiCSBAS_io_lib.py | 4 +--- bin/LiCSBAS_decomposeLOS.py | 6 +++--- bin/LiCSBAS_flt2geotiff.py | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/LiCSBAS_lib/LiCSBAS_io_lib.py b/LiCSBAS_lib/LiCSBAS_io_lib.py index e133e0c..341f614 100644 --- a/LiCSBAS_lib/LiCSBAS_io_lib.py +++ b/LiCSBAS_lib/LiCSBAS_io_lib.py @@ -45,14 +45,12 @@ def make_dummy_bperp(bperp_file, imdates): #%% -def make_geotiff(data, latn_p, lonw_p, dlat, dlon, outfile, compress_option): +def make_geotiff(data, latn_p, lonw_p, dlat, dlon, outfile, compress_option, nodata=None): length, width = data.shape if data.dtype == np.float32: dtype = gdal.GDT_Float32 - nodata = np.nan ## or 0? elif data.dtype == np.uint8: dtype = gdal.GDT_Byte - nodata = None driver = gdal.GetDriverByName('GTiff') outRaster = driver.Create(outfile, width, length, 1, dtype, options=compress_option) diff --git a/bin/LiCSBAS_decomposeLOS.py b/bin/LiCSBAS_decomposeLOS.py index ca0517b..6c836af 100755 --- a/bin/LiCSBAS_decomposeLOS.py +++ b/bin/LiCSBAS_decomposeLOS.py @@ -269,8 +269,8 @@ def main(argv=None): #%% Save geotiff outfileEW = out_prefix + 'EW.geo.tif' outfileUD = out_prefix + 'UD.geo.tif' - io_lib.make_geotiff(ew, lat_n, lon_w, dlat, dlon, outfileEW, compress_option) - io_lib.make_geotiff(ud, lat_n, lon_w, dlat, dlon, outfileUD, compress_option) + io_lib.make_geotiff(ew, lat_n, lon_w, dlat, dlon, outfileEW, compress_option, np.nan) + io_lib.make_geotiff(ud, lat_n, lon_w, dlat, dlon, outfileUD, compress_option, np.nan) #%% Stats @@ -283,7 +283,7 @@ def main(argv=None): (LOSe_part_list[i]*ew_part + LOSu_part_list[i]*ud_part) resid_los = np.zeros_like(bool_valid, dtype=np.float32)*np.nan resid_los[bool_valid] = resid_los_part - io_lib.make_geotiff(resid_los, lat_n, lon_w, dlat, dlon, outfile_resid, compress_option) + io_lib.make_geotiff(resid_los, lat_n, lon_w, dlat, dlon, outfile_resid, compress_option, np.nan) ### n_data outfile_n_data = out_prefix + 'n_data_fromE.geo.tif' diff --git a/bin/LiCSBAS_flt2geotiff.py b/bin/LiCSBAS_flt2geotiff.py index f9e3f24..cb8e067 100755 --- a/bin/LiCSBAS_flt2geotiff.py +++ b/bin/LiCSBAS_flt2geotiff.py @@ -194,7 +194,7 @@ def main(argv=None): if nan2zero_flag: ### Replace nan with 0 data[np.isnan(data)] = 0 - io_lib.make_geotiff(data, lat_n_p, lon_w_p, dlat, dlon, outfile, compress_option) + io_lib.make_geotiff(data, lat_n_p, lon_w_p, dlat, dlon, outfile, compress_option, nodata) #%% Finish