mdbartos / pysheds

:earth_americas: Simple and fast watershed delineation in python.
GNU General Public License v3.0
717 stars 196 forks source link

Accumulation weights not calculating correctly if input weights type is int #149

Closed ar-siddiqui closed 2 years ago

ar-siddiqui commented 3 years ago

I have a direction grid and a weight grid.

When I run accumulation, it does not create correct results if I do not convert the weight grid to float 32 explicitly in line 2 of the following code.

weights = Grid.from_raster(r'C:\Users\asiddiqui\Documents\Projects\NSPECT\HI_SAMPLE_TEST_DATA\original\pysheds\HSG.tif', data_name='soil', nodata = 255)
grid.accumulation(data='dir', weights=weights.soil.astype(np.float32), out_name='acc')
grid.to_raster('acc', r'C:\Users\asiddiqui\Documents\Projects\NSPECT\HI_SAMPLE_TEST_DATA\original\pysheds\acc.tif', dtype=np.float32)

Both datasets are attached.

HSG.zip

mdbartos commented 2 years ago

Greetings,

I just pushed a major update that---among other things---handles types more explicitly. I'd highly recommend upgrading to pysheds v0.3 and seeing if the problem is fixed.

mdbartos commented 2 years ago

Please reopen an issue if the problem persists.