Skip to content

Commit

Permalink
standardized names
Browse files Browse the repository at this point in the history
  • Loading branch information
kcartier-wri committed Nov 4, 2024
1 parent 9ec0285 commit e02bd25
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions city_metrix/layers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ def groupby(self, zones, layer=None):
"""
return LayerGroupBy(self.aggregate, zones, layer, self.masks)

def write(self, bbox, output_path, tile_side_meters=None, buffer_meters=None, **kwargs):
def write(self, bbox, output_path, tile_side_meters=None, tile_buffer_meters=None, **kwargs):
"""
Write the layer to a path. Does not apply masks.
:param bbox: (min x, min y, max x, max y)
:param output_path: local or s3 path to output to
:param tile_side_meters: optional param to tile the results into multiple files specified as tile length on a side in meters
: param buffer_meters: tile buffer distance in meters
: param tile_buffer_meters: tile buffer distance in meters
:return:
"""

if tile_side_meters is None:
clipped_data = self.aggregate.get_data(bbox)
write_layer(output_path, clipped_data)
else:
tile_grid, unbuffered_tile_grid = _get_tile_boundaries(bbox, tile_side_meters, buffer_meters)
tile_grid, unbuffered_tile_grid = _get_tile_boundaries(bbox, tile_side_meters, tile_buffer_meters)

# write raster data to files
if not os.path.exists(output_path):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,23 @@ def test_write_albedo_tiled_unbuffered(target_folder, bbox_info, target_spatial_
file_path = prep_output_path(target_folder, 'albedo_tiled.tif')
target_resolution = target_spatial_resolution_multiplier * get_class_default_spatial_resolution(Albedo())
(Albedo(spatial_resolution=target_resolution).
write(bbox_info.bounds, file_path, tile_side_meters=1000, buffer_meters=None))
write(bbox_info.bounds, file_path, tile_side_meters=1000, tile_buffer_meters=None))
file_count = get_file_count_in_folder(file_path)

assert file_count == 7
expected_file_count = 7 # includes 6 tiles and one geojson file
assert file_count == expected_file_count

@pytest.mark.skipif(RUN_DUMPS == False, reason='Skipping since RUN_DUMPS set to False')
def test_write_albedo_tiled_buffered(target_folder, bbox_info, target_spatial_resolution_multiplier):
buffer_meters = 500
file_path = prep_output_path(target_folder, 'albedo_tiled_buffered.tif')
target_resolution = target_spatial_resolution_multiplier * get_class_default_spatial_resolution(Albedo())
(Albedo(spatial_resolution=target_resolution).
write(bbox_info.bounds, file_path, tile_side_meters=1000, buffer_meters=buffer_meters))
write(bbox_info.bounds, file_path, tile_side_meters=1000, tile_buffer_meters=buffer_meters))
file_count = get_file_count_in_folder(file_path)

assert file_count == 8
expected_file_count = 8 # includes 6 tiles and two geojson files
assert file_count == expected_file_count


@pytest.mark.skipif(RUN_DUMPS == False, reason='Skipping since RUN_DUMPS set to False')
Expand Down

0 comments on commit e02bd25

Please sign in to comment.