Skip to content

Commit

Permalink
renamed default resampling method
Browse files Browse the repository at this point in the history
  • Loading branch information
kcartier-wri committed Dec 18, 2024
1 parent 14bfef6 commit b4ab1b0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions city_metrix/layers/albedo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

Expand Down
1 change: 1 addition & 0 deletions city_metrix/layers/alos_dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 7 additions & 6 deletions city_metrix/layers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
1 change: 1 addition & 0 deletions city_metrix/layers/nasa_dem.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions tests/test_layer_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b4ab1b0

Please sign in to comment.