#NEWLINE# def __init__( self , raster , affine = None , nodata = None , band = 1 ) : #NEWLINE# #INDENT# self . drivers = None #NEWLINE# self . array = None #NEWLINE# self . src = None #NEWLINE# if isinstance ( raster , np . ndarray ) : #NEWLINE# #INDENT# if ( affine is None ) : #NEWLINE# #INDENT# raise ValueError ( 'Must specify affine for numpy arrays' ) #NEWLINE# #UNINDENT# self . array = raster #NEWLINE# self . affine = affine #NEWLINE# self . shape = raster . shape #NEWLINE# self . nodata = nodata #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . drivers = rasterio . drivers ( ) #NEWLINE# self . src = rasterio . open ( raster , 'r' ) #NEWLINE# self . affine = self . src . affine #NEWLINE# self . shape = ( self . src . height , self . src . width ) #NEWLINE# self . band = band #NEWLINE# if ( nodata is not None ) : #NEWLINE# #INDENT# self . nodata = float ( nodata ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . nodata = self . src . nodata