Skip to content
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
11 changes: 10 additions & 1 deletion hydromt_fiat/fiat.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,15 @@ def setup_hazard(
da.encoding["_FillValue"] = None
da = da.raster.gdal_compliant()

# ensure variable name is lowercase, since FIAT seems to be failing if not # TODO check with FIAT
da_name = da_name.lower()
da = da.rename(da_name)

# Check if map is rotated and if yes, reproject to a non-rotated grid
if "xc" in da.coords:
self.logger.warning("Hazard map is rotated. It will be reprojected to a none rotated grid using nearest neighbor interpolation")
da = da.raster.reproject(dst_crs=da.rio.crs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully familiar how the grid rotation works best, but according to chatgpt this code may fail if the crs is not in standard projection like UTM or WGS84. Maybe you could comment on that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It uses epsg codes from what I saw. So if there is an epsg code related to you projection it should work.

# check masp projection, null data, and grids
check_maps_metadata(self.staticmaps, params, da, da_name, idx)

Expand Down Expand Up @@ -847,7 +856,7 @@ def setup_hazard(
)

self.set_config(
"hazard.elevation_reference", "dem" if da_type == "water_depth" else "datum"
"hazard.elevation_reference", "DEM" if da_type == "water_depth" else "datum"
)

# Set the configurations for a multiband netcdf
Expand Down