From baef0b63bcaa28c6ea8d96295259eeed025ea59a Mon Sep 17 00:00:00 2001 From: James Douglass Date: Tue, 6 Feb 2024 14:52:12 -0800 Subject: [PATCH 1/4] We were using the wrong variable name. RE:#368 --- src/pygeoprocessing/geoprocessing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pygeoprocessing/geoprocessing.py b/src/pygeoprocessing/geoprocessing.py index 7b572962..d87d986b 100644 --- a/src/pygeoprocessing/geoprocessing.py +++ b/src/pygeoprocessing/geoprocessing.py @@ -1897,7 +1897,7 @@ def default_aggregate_dict(): creationOptions=DEFAULT_GTIFF_CREATION_TUPLE_OPTIONS[1], callback=_make_logger_callback( f'rasterizing disjoint polygon set {i + 1} of ' - f'{len(disjoint_fid_set)} set %.1f%% complete (%s)'), + f'{len(disjoint_fid_sets)} set %.1f%% complete (%s)'), where=(f'{fid_field_name} IN ({fid_set_str})')) fid_raster_paths.append(fid_raster_path) From 2e9d4e99a13f97d0b592081aa19266209b28ee35 Mon Sep 17 00:00:00 2001 From: James Douglass Date: Tue, 6 Feb 2024 14:52:42 -0800 Subject: [PATCH 2/4] Making a log message more readable. RE:#368 --- src/pygeoprocessing/geoprocessing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pygeoprocessing/geoprocessing.py b/src/pygeoprocessing/geoprocessing.py index d87d986b..bb7f38f9 100644 --- a/src/pygeoprocessing/geoprocessing.py +++ b/src/pygeoprocessing/geoprocessing.py @@ -2796,7 +2796,7 @@ def rasterize( "%s doesn't exist, but needed to rasterize." % target_raster_path) rasterize_callback = _make_logger_callback( - "RasterizeLayer %.1f%% complete %s") + "pygeoprocessing.rasterize RasterizeLayer %.1f%% complete %s") if burn_values is None: burn_values = [] From ac921e283366926fedc9232139f87e2e60e7a845 Mon Sep 17 00:00:00 2001 From: James Douglass Date: Tue, 6 Feb 2024 14:53:07 -0800 Subject: [PATCH 3/4] Light linting. RE:#368. --- src/pygeoprocessing/geoprocessing.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pygeoprocessing/geoprocessing.py b/src/pygeoprocessing/geoprocessing.py index bb7f38f9..85b267b3 100644 --- a/src/pygeoprocessing/geoprocessing.py +++ b/src/pygeoprocessing/geoprocessing.py @@ -1890,7 +1890,7 @@ def default_aggregate_dict(): attribute=fid_field_name, noData=fid_nodata, outputBounds=aligned_bbox, - xRes=abs(raster_info['pixel_size'][0]), # resolution should always be positive + xRes=abs(raster_info['pixel_size'][0]), # resolution must be > 0 yRes=abs(raster_info['pixel_size'][1]), format='GTIFF', outputType=gdal.GDT_UInt16, @@ -1912,11 +1912,12 @@ def default_aggregate_dict(): nodata = get_raster_info(raster_path)['nodata'][band - 1] data_source = gdal.OpenEx(raster_path, gdal.OF_RASTER) data_band = data_source.GetRasterBand(band) - found_fids = set() # track FIDs that have been found on at least one pixel + found_fids = set() # track FIDs found on at least one pixel for set_index, fid_raster_path in enumerate(fid_raster_paths): LOGGER.info( - f'disjoint polygon set {set_index} of {len(fid_raster_paths)}') + f'disjoint polygon set {set_index + 1} of ' + f'{len(fid_raster_paths)}') fid_raster = gdal.OpenEx(fid_raster_path, gdal.OF_RASTER) fid_band = fid_raster.GetRasterBand(1) From 74a02f0d87d658c71f75906ddfb34ea2a8ff7acf Mon Sep 17 00:00:00 2001 From: James Douglass Date: Tue, 6 Feb 2024 14:54:27 -0800 Subject: [PATCH 4/4] Noting change in HISTORY. RE:#368 --- HISTORY.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/HISTORY.rst b/HISTORY.rst index 4825b6ea..ba4edf74 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -20,6 +20,9 @@ Unreleased Changes provided instead of a vector. If both are provided, the mask raster alone is used. The new mask raster must have the same dimensions and geotransform as the output warped raster. https://github.com/natcap/pygeoprocessing/issues/366 +* Fixed a bug in ``zonal_statistics`` where the wrong number of disjoint + polygon sets were being reported in the logs. + https://github.com/natcap/pygeoprocessing/issues/368 2.4.2 (2023-10-24) ------------------