Skip to content

Commit

Permalink
Add test for multiband rasters
Browse files Browse the repository at this point in the history
  • Loading branch information
mdbartos committed Feb 26, 2022
1 parent f1412e6 commit dad919b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Binary file added data/cogeo.tiff
Binary file not shown.
10 changes: 6 additions & 4 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
dir_path = os.path.join(data_dir, 'dir.asc')
dem_path = os.path.join(data_dir, 'dem.tif')
roi_path = os.path.join(data_dir, 'roi.tif')
multiband_path = os.path.join(data_dir, 'cogeo.tiff')
feature_geometry = [{'type': 'Polygon',
'coordinates': (((-97.29749977660477, 32.74000135435936),
(-97.29083107907053, 32.74000328969928),
Expand Down Expand Up @@ -331,21 +332,22 @@ def test_cell_slopes():
slopes_dinf = grid.cell_slopes(dem, fdir_dinf, routing='dinf')
slopes_mfd = grid.cell_slopes(dem, fdir_mfd, routing='mfd')

# def test_set_nodata():
# grid.set_nodata('dir', 0)

def test_to_ascii():
catch = d.catch
fdir = d.fdir
grid.clip_to(catch)
# np.float is depreciated
grid.to_ascii(fdir, 'test_dir.asc', target_view=fdir.viewfinder, dtype=np.float64)
fdir_out = grid.read_ascii('test_dir.asc', dtype=np.uint8)
assert((fdir_out == fdir).all())
grid.to_ascii(fdir, 'test_dir.asc', dtype=np.uint8)
fdir_out = grid.read_ascii('test_dir.asc', dtype=np.uint8)
assert((fdir_out == grid.view(fdir)).all())

def test_read_raster():
band_1 = grid.read_raster(multiband_path, band=1)
band_2 = grid.read_raster(multiband_path, band=2)
band_3 = grid.read_raster(multiband_path, band=3)

def test_to_raster():
catch = d.catch
fdir = d.fdir
Expand Down

0 comments on commit dad919b

Please sign in to comment.