Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added nodata value to raster before writing #199

Merged
merged 4 commits into from
Jun 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hydromt_sfincs/sfincs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3398,6 +3398,9 @@ def write_raster(
f"Variable {attr}.{layer} has more than 2 dimensions: skipping."
)
continue
# If the raster type is float, set nodata to np.nan
if da.dtype == "float32" or da.dtype == "float64":
da.raster.set_nodata(np.nan)
# only write active cells to gis files
da = da.where(self.mask > 0, da.raster.nodata).raster.mask_nodata()
if da.raster.res[1] > 0: # make sure orientation is N->S
Expand Down
Loading