Skip to content

Commit

Permalink
gis:
Browse files Browse the repository at this point in the history
 - ensure coherent boolean type in shape_availability function
 - ensure integer type of mask in rasterio reproject function in shape_availability_reprojected
  • Loading branch information
FabianHofmann committed Jun 9, 2022
1 parent c67bebd commit 31f9b0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions atlite/gis.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,14 +448,14 @@ def shape_availability(geometry, excluder):
)
if d["codes"]:
if callable(d["codes"]):
masked_ = d["codes"](masked)
masked_ = d["codes"](masked).astype(bool)
else:
masked_ = isin(masked, d["codes"])
else:
masked_ = masked
masked_ = masked.astype(bool)

if d["invert"]:
masked_ = ~(masked_).astype(bool)
masked_ = ~masked_
if d["buffer"]:
iterations = int(d["buffer"] / excluder.res) + 1
masked_ = dilation(masked_, iterations=iterations)
Expand Down Expand Up @@ -508,7 +508,7 @@ def shape_availability_reprojected(
masked, transform, dst_transform, excluder.crs, dst_crs
)
return rio.warp.reproject(
masked,
masked.astype(np.uint8),
empty(dst_shape),
resampling=rio.warp.Resampling.average,
src_transform=transform,
Expand Down

0 comments on commit 31f9b0d

Please sign in to comment.