Search code examples
pythonattributeerror

Getting Error with "from_raster" attribute in pysheds


This is my first time asking a question. I am trying to use "pysheds" to analyze some hydrologic DEM files. The developer as some pretty thorough "how to" videos but when I try to load the DEM file in the way that they show I get the following error:

module 'pysheds.grid' has no attribute 'from_raster'

here's my code

    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.colors as colors
    import geopandas as gpd
    import pysheds
    import pysheds.grid as Grid
    import mplleaflet
    
    grid = Grid.from_raster('path.tif', data_name = 'dem')`

I checked the print(dir(Grid)) in the console and didn't see this attribute listed.

Am I missing something? Thanks!


Solution

  • According to documentation, you should import Grid from pysheds.grid like this:

    from pysheds.grid import Grid
    
    grid = Grid.from_raster('n30w100_con', data_name='dem')
    grid.read_raster('n30w100_dir', data_name='dir')
    grid.view('dem')
    

    instead of

    import pysheds.grid as Grid