mdbartos / pysheds

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

Can't 'imshow' DEM for some unkown reason #231

Open ronativ opened 9 months ago

ronativ commented 9 months ago

Hi,

When using the following code:

fig, ax = plt.subplots(figsize=(8,6)) plt.imshow(grid.dem, extent=grid.extent, cmap='cubehelix', zorder=1) plt.colorbar(label='Elevation (m)') plt.title('Digital elevation map') plt.xlabel('Longitude') plt.ylabel('Latitude')

I get the following error:

AttributeError: 'sGrid' object has no attribute 'dem'

Even though I did use grid = Grid.from_raster('.../example/dem.tif')

Any thoughts on this issue?

Thanks! R.

everettsp commented 2 months ago

The grid doesn't store the DEM, you have to load it separately using dem = grid.read_raster('.../example/dem.tif')