#NEWLINE# def statistics( self , refresh = False , approximate = False ) : #NEWLINE# #INDENT# '\n        Compute statistics on the pixel values of this band.\n\n        The return value is a tuple with the following structure:\n        (minimum, maximum, mean, standard deviation).\n\n        If approximate=True, the statistics may be computed based on overviews\n        or a subset of image tiles.\n\n        If refresh=True, the statistics will be computed from the data directly,\n        and the cache will be updated where applicable.\n\n        For empty bands (where all pixel values are nodata), all statistics\n        values are returned as None.\n\n        For raster formats using Persistent Auxiliary Metadata (PAM) services,\n        the statistics might be cached in an auxiliary file.\n        ' #NEWLINE# ( smin , smax , smean , sstd ) = ( c_double ( ) , c_double ( ) , c_double ( ) , c_double ( ) ) #NEWLINE# stats_args = [ self . _ptr , c_int ( approximate ) , byref ( smin ) , byref ( smax ) , byref ( smean ) , byref ( sstd ) , c_void_p ( ) , c_void_p ( ) ] #NEWLINE# if ( refresh or self . _stats_refresh ) : #NEWLINE# #INDENT# capi . compute_band_statistics ( * stats_args ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# force = True #NEWLINE# stats_args . insert ( 2 , c_int ( force ) ) #NEWLINE# capi . get_band_statistics ( * stats_args ) #NEWLINE# #UNINDENT# result = ( smin . value , smax . value , smean . value , sstd . value ) #NEWLINE# if any ( ( math . isnan ( smean ) for val in result ) ) : #NEWLINE# #INDENT# result = ( None , None , None , None ) #NEWLINE# #UNINDENT# self . _stats_refresh = False #NEWLINE# return result