Skip to content

Commit

Permalink
Small update about nodata
Browse files Browse the repository at this point in the history
  • Loading branch information
yumorishita committed Feb 9, 2021
1 parent b39223f commit 5ddc43b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 1 addition & 3 deletions LiCSBAS_lib/LiCSBAS_io_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions bin/LiCSBAS_decomposeLOS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion bin/LiCSBAS_flt2geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5ddc43b

Please sign in to comment.