def read(self, bounds=None, window=None, masked=False, nan_as_nodata=False):
        # Calculate the window
        if bounds and window:
            raise ValueError("Specify either bounds or window")

        if bounds:
            win = bounds_window(bounds, self.affine)
        elif window:
            win = window
        else:
            raise ValueError("Specify either bounds or window")

        c, _, _, f = window_bounds(win, self.affine)  # c ~ west, f ~ north
        a, b, _, d, e, _, _, _, _ = tuple(self.affine)
        new_affine = Affine(a, b, c, d, e, f)

        nodata = self.nodata
        if nodata is None:
            nodata = -999
            warnings.warn("Setting nodata to -999; specify nodata explicitly")

        if self.array is not None:
            # It's an ndarray already
            new_array = boundless_array(self.array, window=win, nodata=nodata, masked=masked)
        elif self.src:
            # It's an open rasterio dataset
            new_array = self.src.read(self.band, window=win, boundless=True, masked=masked)

        if nan_as_nodata:
            nans = np.isnan(new_array)
            if nans.any():
                if masked:
                    # TODO would need to set nan = nodata and remask
                    raise NotImplementedError("specify nan_as_nodata OR masked")
                else:
                    new_array[nans] = nodata

        return Raster(new_array, new_affine, nodata)
Check if the server is alive
dataset/ETHPy150Open perrygeo/python-rasterstats/src/rasterstats/io.py/Raster.read--crossover with--dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/contrib/pymysql/connections.py/Connection.ping