def matrix(self, band=1, mask_nan=True):
        """
        read a raster band (subset) into a numpy ndarray

        Parameters
        ----------
        band: int
            the band to read the matrix from; 1-based indexing
        mask_nan: bool
            convert nodata values to :obj:`numpy.nan`? As :obj:`numpy.nan` requires at least float values, any integer array is cast
            to float32.

        Returns
        -------
        numpy.ndarray
            the matrix (subset) of the selected band
        """
        
        mat = self.__data[band - 1]
        if mat is None:
            mat = self.raster.GetRasterBand(band).ReadAsArray()
            if mask_nan:
                if isinstance(self.nodata, list):
                    nodata = self.nodata[band - 1]
                else:
                    nodata = self.nodata
                try:
                    mat[mat == nodata] = np.nan
                except ValueError:
                    mat = mat.astype('float32')
                    mat[mat == nodata] = np.nan
        return mat
def matrix ( self , band = 1 , mask_nan = True ) : mat = self . __data [ band - 1 ] if mat is None : mat = self . raster . GetRasterBand ( band ) . ReadAsArray ( ) if mask_nan : if isinstance ( self . nodata , list ) : nodata = self . nodata [ band - 1 ] else : nodata = self . nodata try : mat [ mat == nodata ] = np . nan except ValueError : mat = mat . astype ( 'float32' ) mat [ mat == nodata ] = np . nan return mat
read a raster band (subset) into a numpy ndarray

        Parameters
        ----------
        band: int
            the band to read the matrix from; 1-based indexing
        mask_nan: bool
            convert nodata values to :obj:`numpy.nan`? As :obj:`numpy.nan` requires at least float values, any integer array is cast
            to float32.

        Returns
        -------
        numpy.ndarray
            the matrix (subset) of the selected band