mdbartos / pysheds

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

Grid not picking no data value by default #148

Closed ar-siddiqui closed 2 years ago

ar-siddiqui commented 2 years ago

My data has nodata = 255 but when I run the following code weights.soil does not have nan for 255

weights = Grid.from_raster(r'C:\Users\asiddiqui\Documents\Projects\NSPECT\HI_SAMPLE_TEST_DATA\original\pysheds\HSG.tif', data_name='soil')

my expectation was that the grid would have nan in place of 255.

Does pysheds not pick nodata val by default?

HSG.zip

mdbartos commented 2 years ago

Greetings,

Try upgrading to pysheds v0.3 and seeing if the issue is fixed. Note that if no nodata value is found in the raster file, it will default to 0 for compatibility with different dtypes.

Also note that datasets as named attributes of Grid are now removed. from_raster now returns an instantiated grid, and read_raster will return the actual data. nodata can also be passed as a kwarg to read_raster

mdbartos commented 2 years ago

Please reopen if this problem persists.