From 22a6e63bbcb88eec0ebb8f3f13e0bd4000b5c0f8 Mon Sep 17 00:00:00 2001 From: Kat Matson Date: Wed, 12 Jun 2024 17:31:24 +0000 Subject: [PATCH] Create a 'bucketed_count' statistic in the config that will group elements into buckets based on the property and ranges in the config. The implementation of this statistic will primarily be in viz-raster. --- pdgstaging/ConfigManager.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pdgstaging/ConfigManager.py b/pdgstaging/ConfigManager.py index 187063e..3a6d2ee 100644 --- a/pdgstaging/ConfigManager.py +++ b/pdgstaging/ConfigManager.py @@ -185,7 +185,17 @@ class ConfigManager(): aggregation method will be used to summarize the given property in the cell. Method can be any method allowed in the 'func' property of the panda's aggregate method, - e.g. 'sum', 'count', 'mean', etc. + e.g. 'sum', 'count', 'mean', etc., or 'bounded_count'. + For 'bounded_count', a 'bounds' tuple is required and + 'weight_by' is ignored because 'count' is already + implied. + - bounds : tuple + An upper and lower bound for the value of 'property' + for the element to be included in the count. Only + used if 'aggregation_method' is 'bounded_count'. If one + of the bounds is None, the accepted values for + 'property' are unbounded in that direction. The upper + bound is inclusive and the lower bound is exclusive. - resampling_method : str The resampling method to use when combining raster data from child tiles into parent tiles. See rasterio's @@ -1163,11 +1173,13 @@ def get_raster_config(self): 'name', 'weight_by', 'property', - 'aggregation_method') + 'aggregation_method', + 'bounds' + ) stats_config = [] for stat_config in self.config['statistics']: stats_config.append( - {k: stat_config[k] for k in stats_config_keys} + {k: stat_config[k] for k in stats_config_keys if k in stat_config} ) raster_config = {