diff --git a/city_metrix/layers/albedo.py b/city_metrix/layers/albedo.py index 8596b7d..da63bb1 100644 --- a/city_metrix/layers/albedo.py +++ b/city_metrix/layers/albedo.py @@ -9,6 +9,7 @@ class Albedo(Layer): start_date: starting date for data retrieval end_date: ending date for data retrieval spatial_resolution: raster resolution in meters (see https://github.com/stac-extensions/raster) + resampling_method: interpolation method used by Google Earth Engine. Albedo default is 'bilinear'. All options are: ('bilinear', 'bicubic', 'default'). threshold: threshold value for filtering the retrieval """ diff --git a/city_metrix/layers/alos_dsm.py b/city_metrix/layers/alos_dsm.py index e1618db..ca34ef6 100644 --- a/city_metrix/layers/alos_dsm.py +++ b/city_metrix/layers/alos_dsm.py @@ -7,6 +7,7 @@ class AlosDSM(Layer): """ Attributes: spatial_resolution: raster resolution in meters (see https://github.com/stac-extensions/raster) + resampling_method: interpolation method used by Google Earth Engine. AlosDSM default is 'bilinear'. All options are: ('bilinear', 'bicubic', 'default'). """ def __init__(self, spatial_resolution=30, resampling_method='bilinear', **kwargs): diff --git a/city_metrix/layers/layer.py b/city_metrix/layers/layer.py index c41991e..d30deeb 100644 --- a/city_metrix/layers/layer.py +++ b/city_metrix/layers/layer.py @@ -324,16 +324,17 @@ def get_stats_funcs(stats_func): def set_resampling_method(dataset, resampling_method): - valid_raster_resampling_methods = ['bilinear', 'bicubic', 'nearest'] + valid_raster_resampling_methods = ['bilinear', 'bicubic', 'default'] if resampling_method not in valid_raster_resampling_methods: - raise ValueError(f'Invalid resampling method ({resampling_method}). ' - f'Valid methods: ({valid_raster_resampling_methods})') + raise ValueError(f"Invalid resampling method ('{resampling_method}'). " + f"Valid methods: {valid_raster_resampling_methods}") - if resampling_method != 'nearest': - data = dataset.resample(resampling_method) - else: + if resampling_method == 'default': data = dataset + else: + data = dataset.resample(resampling_method) + return data diff --git a/city_metrix/layers/nasa_dem.py b/city_metrix/layers/nasa_dem.py index dab201a..baf66af 100644 --- a/city_metrix/layers/nasa_dem.py +++ b/city_metrix/layers/nasa_dem.py @@ -7,6 +7,7 @@ class NasaDEM(Layer): """ Attributes: spatial_resolution: raster resolution in meters (see https://github.com/stac-extensions/raster) + resampling_method: interpolation method used by Google Earth Engine. NasaDEM default is 'bilinear'. All options are: ('bilinear', 'bicubic', 'default'). """ def __init__(self, spatial_resolution=30, resampling_method='bilinear', **kwargs): diff --git a/tests/test_layer_metrics.py b/tests/test_layer_metrics.py index 570b1f1..434b211 100644 --- a/tests/test_layer_metrics.py +++ b/tests/test_layer_metrics.py @@ -48,9 +48,10 @@ def test_read_image_collection_scale(): ) def test_albedo_metrics(): - # data = Albedo(spatial_resolution=10, resampling_method='nearest').get_data(BBOX) + data = Albedo(spatial_resolution=10).get_data(BBOX) + # data = Albedo(spatial_resolution=10, resampling_method='default').get_data(BBOX) # data = Albedo(spatial_resolution=10, resampling_method='bilinear').get_data(BBOX) - data = Albedo(spatial_resolution=10, resampling_method='bicubic').get_data(BBOX) + # data = Albedo(spatial_resolution=10, resampling_method='bicubic').get_data(BBOX) # Bounding values expected_min_value = _convert_fraction_to_rounded_percent(0.03)