Skip to content

Commit d3095e0

Browse files
committed
Make sure DEM rasters (esp. 50cm) are rounded to 1/128m for optimal compression
1 parent b8edd90 commit d3095e0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

batch_mask.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,13 @@ def mask_rasters(maskFile, suffix_maskval_dict, args):
913913

914914
print("Source NoData value: {}".format(src_nodataval))
915915

916+
if np.issubdtype(dst_array.dtype, np.floating) and src_nodataval == -9999:
917+
print("Assuming floating point NoData=-9999 raster is a DEM")
918+
print("Rounding DEM values to nearest 1/128 meters (~1cm) for optimal output compression")
919+
np.multiply(dst_array, 128.0, out=dst_array)
920+
np.round_(dst_array, decimals=0, out=dst_array)
921+
np.divide(dst_array, 128.0, out=dst_array)
922+
916923
# Set masking value to source NoDataVal if necessary.
917924
if maskval is None:
918925
if src_nodataval is None:

0 commit comments

Comments
 (0)