#NEWLINE# def has_data( self ) : #NEWLINE# #INDENT# 'Check if the reprojection gave rise to a tile with valid data.\n\n        Open the file and check if there is data' #NEWLINE# tile_dataset = gdal . Open ( self . temp_tile_output_path ) #NEWLINE# start_datetime = datetime . now ( ) #NEWLINE# if ( tile_dataset . RasterCount != len ( self . band_stack . band_dict ) ) : #NEWLINE# #INDENT# raise DatasetError ( ( ( ( 'Number of layers (%d) in tile file\n %s\n' + 'does not match number of bands ' ) + '(%d) from database.' ) % ( tile_dataset . RasterCount , self . temp_tile_output_path , len ( self . band_stack . band_dict ) ) ) ) #NEWLINE# #UNINDENT# band_list = [ self . band_stack . band_dict [ file_number ] for file_number in sorted ( self . band_stack . band_dict . keys ( ) , key = ( lambda file_number : self . band_stack . band_dict [ file_number ] [ 'tile_layer' ] ) ) ] #NEWLINE# result = False #NEWLINE# for band_index in range ( tile_dataset . RasterCount ) : #NEWLINE# #INDENT# band_no = ( band_index + 1 ) #NEWLINE# band = tile_dataset . GetRasterBand ( band_no ) #NEWLINE# band_data = band . ReadAsArray ( ) #NEWLINE# nodata_val = band_list [ band_index ] [ 'nodata_value' ] #NEWLINE# if ( nodata_val is None ) : #NEWLINE# #INDENT# nodata_val = band . GetNoDataValue ( ) #NEWLINE# #UNINDENT# LOGGER . debug ( 'nodata_val = %s for layer %d' , nodata_val , band_no ) #NEWLINE# if ( nodata_val is None ) : #NEWLINE# #INDENT# if ( self . band_stack . band_dict [ file_number ] [ 'level_name' ] == 'PQA' ) : #NEWLINE# #INDENT# if ( np . bitwise_and ( band_data , PQA_CONTIGUITY ) > 0 ) . any ( ) : #NEWLINE# #INDENT# LOGGER . debug ( 'Tile is not empty: PQA data contains some contiguous data' ) #NEWLINE# result = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# LOGGER . debug ( 'Tile is not empty: No-data value is not set' ) #NEWLINE# result = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( band_data != nodata_val ) . any ( ) : #NEWLINE# #INDENT# LOGGER . debug ( 'Tile is not empty: Some values != %s' , tile_dataset ) #NEWLINE# result = True #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# LOGGER . info ( ( ( 'Tile ' + ( 'has data' if result else 'is empty' ) ) + '.' ) ) #NEWLINE# LOGGER . debug ( 'Empty tile detection time = %s' , ( datetime . now ( ) - start_datetime ) ) #NEWLINE# return result