Skip to content

Commit

Permalink
Cleaning up a conditional. RE:natcap#1293
Browse files Browse the repository at this point in the history
  • Loading branch information
phargogh committed Oct 1, 2024
1 parent e6eb1a0 commit 94f7f00
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/natcap/invest/urban_nature_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -2542,23 +2542,23 @@ def _warp_lulc(source_lulc_path, target_lulc_path, target_pixel_size,
"""
source_raster_info = pygeoprocessing.get_raster_info(source_lulc_path)
target_nodata = source_raster_info['nodata'][0]
if target_nodata is None:
# Guarantee that our nodata cannot be represented by the datatype -
# select a nodata value that's out of range.
target_nodata = pygeoprocessing.choose_nodata(
source_raster_info['numpy_type']) + 1

pygeoprocessing.warp_raster(
source_lulc_path, target_pixel_size, target_lulc_path,
'near', target_bb=target_bounding_box,
target_projection_wkt=source_raster_info['projection_wkt'])

# if there is no defined nodata, set a default value
raster = gdal.OpenEx(target_lulc_path, gdal.GA_Update)
band = raster.GetRasterBand(1)
band.SetNoDataValue(target_nodata)
band = None
raster = None
if target_nodata is None:
# Guarantee that our nodata cannot be represented by the datatype -
# select a nodata value that's out of range.
target_nodata = pygeoprocessing.choose_nodata(
source_raster_info['numpy_type']) + 1
raster = gdal.OpenEx(target_lulc_path, gdal.GA_Update)
band = raster.GetRasterBand(1)
band.SetNoDataValue(target_nodata)
band = None
raster = None


def _mask_raster(source_raster_path, mask_raster_path, target_raster_path):
Expand Down

0 comments on commit 94f7f00

Please sign in to comment.