Skip to content

Commit

Permalink
ensure robust to no LiDAR dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
rosepearson committed Nov 15, 2023
1 parent 7783462 commit 6ced4a7
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/geofabrics/dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,32 @@ def add_lidar(
}

# Don't use dask delayed if there is no chunking
if chunk_size is None:
if len(lidar_datasets_info) == 0:
# Create an empty dataset as no LiDAR
logging.warning("No LiDAR dataset. Creating an empty raw DEM dataset.")
bounds = self.catchment_geometry.catchment.geometry.bounds
resolution = self.catchment_geometry.resolution
x = numpy.arange(
numpy.ceil(bounds.minx.min() / resolution) * resolution,
numpy.ceil(bounds.maxx.max() / resolution) * resolution,
resolution,
dtype=raster_options["raster_type"],
)
y = numpy.arange(
numpy.ceil(bounds.maxy.max() / resolution) * resolution,
numpy.ceil(bounds.miny.min() / resolution) * resolution,
-resolution,
dtype=raster_options["raster_type"],
)
metadata["instructions"]["dataset_mapping"]["lidar"] = {"no LiDAR": self.SOURCE_CLASSIFICATION["no data"]}
elevations = {"no LiDAR": dask.array.empty(shape=(len(y), len(x)), dtype=raster_options["raster_type"])}
dem = self._create_data_set(
x=x,
y=y,
elevations=elevations,
metadata=metadata,
)
elif chunk_size is None:
dem = self._add_lidar_no_chunking(
lidar_datasets_info=lidar_datasets_info,
options=raster_options,
Expand Down

0 comments on commit 6ced4a7

Please sign in to comment.