Skip to content

Commit

Permalink
Add support for setting road roughness' and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepearson committed Oct 13, 2024
1 parent f36cb58 commit 865484e
Show file tree
Hide file tree
Showing 6 changed files with 249 additions and 166 deletions.
23 changes: 23 additions & 0 deletions src/geofabrics/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,29 @@ def add_lidar(
self._dem = self._dem.where(mask)
self._write_netcdf_conventions_in_place(self._dem, self.catchment_geometry.crs)

def add_roads(self, roads_polygon: dict):
"""Set roads to paved and unpaved roughness values.
Parameters
----------
roads_polygon
Dataframe with polygon and associated roughness values
"""


# Set unpaved roads
mask = clip_mask(
self._dem.z, roads_polygon[roads_polygon["surface"]=="unpaved"], self.chunk_size
)
self._dem["zo"] = self._dem.zo.where(~mask, self.default_values["unpaved"])
# Then set paved roads
mask = clip_mask(
self._dem.z, roads_polygon[roads_polygon["surface"]=="paved"], self.chunk_size
)
self._dem["zo"] = self._dem.zo.where(~mask, self.default_values["paved"])
self._write_netcdf_conventions_in_place(self._dem, self.catchment_geometry.crs)

def _add_tiled_lidar_chunked(
self,
lidar_datasets_info: dict,
Expand Down
Loading

0 comments on commit 865484e

Please sign in to comment.