Skip to content

Commit dfad3f0

Browse files
committed
fix(hairy-tiles): fix wrong recognition of no-data values (#44)
1 parent 3888215 commit dfad3f0

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ Error: /src/data/cat_aggr_buf_30m/input/vector/osm_merged_2012.gpkg_transformed.
177177
**Solution**: run the command again with the same parameters.
178178
- **Warning**: if you delete stressors, you would have to calculate them again using the 3d command to proceed with the 4th command.
179179

180-
Not each issue is known so far, so if you have faced something different, please let us know by opening a new issue.
180+
Not each issue is known so far, so if you have faced something different, please let us know by opening a new issue. **All relevant issues are mentioned** [**here**](https://github.com/AD4GD/pilot-2/issues).
181181

182182
#### Further development
183183
This tool is mostly complete, but a few improvements could be made if there is demand from users.
8 KB
Binary file not shown.

src/enrichment/lulc_enrichment_wrapper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ def mask_raster_with_raster(self, input_raster, mask_raster, nodata_value, outpu
447447
# get raster properties
448448
in_band = in_ds.GetRasterBand(1)
449449
mask_band = mask_ds.GetRasterBand(1)
450+
mask_nodata_val = mask_band.GetNoDataValue()
451+
print(f"Nodata value of the masking raster dataset: {mask_nodata_val}")
452+
450453
out_driver = gdal.GetDriverByName('GTiff')
451454
if output_raster is None:
452455
out_ds = gdal.Open(input_raster, gdal.GA_Update)
@@ -458,7 +461,7 @@ def mask_raster_with_raster(self, input_raster, mask_raster, nodata_value, outpu
458461

459462
# create a mask array from the mask raster
460463
mask_data = mask_band.ReadAsArray()
461-
mask_data[mask_data == 0] = nodata_value
464+
mask_data[mask_data == mask_nodata_val] = nodata_value
462465

463466
# apply the mask to the input raster
464467
in_data = in_band.ReadAsArray()

0 commit comments

Comments
 (0)