5050 TOTAL_OBSERVATION_NAME )
5151# Builder
5252from . import get_srid_column
53- from .image import (SmartDataSet , generate_cogs , linear_raster_scale , raster_convexhull , raster_extent , rescale ,
54- save_as_cog )
53+ from .image import (SmartDataSet , generate_cogs , get_resample_method , linear_raster_scale , raster_convexhull ,
54+ raster_extent , rescale , save_as_cog )
5555from .index_generator import generate_band_indexes
5656from .strings import StringFormatter
5757
@@ -236,7 +236,8 @@ def merge(merge_file: str, mask: dict, assets: List[dict], band: str,
236236
237237 if quality_band == band :
238238 source_nodata = nodata = float (mask ['nodata' ])
239- # Only apply bilinear (change pixel values) for band values
239+ elif "resampling" in kwargs :
240+ resampling = get_resample_method (kwargs ["resampling" ])
240241 elif (mask and mask .get ('saturated_band' ) != band ) or quality_band is None :
241242 resampling = Resampling .bilinear
242243
@@ -796,6 +797,16 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
796797 saturated = radsat_extract_bits (saturated , 1 , 7 ).astype (numpy .bool_ )
797798 masked .mask [saturated ] = True
798799
800+ # Get current observation file name
801+ file_path = bandlist [order ].name
802+ file_date = datetime .strptime (merges_band_map [file_path ], '%Y-%m-%d' )
803+ day_of_year = file_date .timetuple ().tm_yday
804+
805+ if build_clear_observation and is_combined_collection :
806+ datasource_block = provenance_merge_map [file_date .strftime ('%Y-%m-%d' )].dataset .read (1 , window = window )
807+ if mask_values ['bits' ]:
808+ confidence .oli = numpy .isin (datasource_block , index_landsat_oli )
809+
799810 if mask_values ['bits' ]:
800811 matched = get_qa_mask (masked ,
801812 clear_data = clear_values ,
@@ -828,16 +839,6 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
828839
829840 stack_total_observation [window .row_off : row_offset , window .col_off : col_offset ] += copy_mask .astype (numpy .uint8 )
830841
831- # Get current observation file name
832- file_path = bandlist [order ].name
833- file_date = datetime .strptime (merges_band_map [file_path ], '%Y-%m-%d' )
834- day_of_year = file_date .timetuple ().tm_yday
835-
836- if build_clear_observation and is_combined_collection :
837- datasource_block = provenance_merge_map [file_date .strftime ('%Y-%m-%d' )].dataset .read (1 , window = window )
838- if mask_values ['bits' ]:
839- confidence .oli = datasource_block == index_landsat_oli
840-
841842 # Find all no data in destination STACK image
842843 stack_raster_where_nodata = numpy .where (
843844 stack_raster [window .row_off : row_offset , window .col_off : col_offset ] == nodata
@@ -848,9 +849,6 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
848849 stack_raster [window .row_off : row_offset ,
849850 window .col_off : col_offset ].shape )
850851
851- if build_clear_observation and is_combined_collection :
852- datasource_block = provenance_merge_map [file_date .strftime ('%Y-%m-%d' )].dataset .read (1 , window = window )
853-
854852 # Find all valid/cloud in destination STACK image
855853 raster_where_data = numpy .where (raster != nodata )
856854 raster_data_pos = numpy .ravel_multi_index (raster_where_data , raster .shape )
@@ -952,7 +950,7 @@ def blend(activity, band_map, quality_band, build_clear_observation=False, block
952950 provenance_file = build_cube_path (datacube , period , tile_id , version = version ,
953951 band = PROVENANCE_NAME , composed = True , ** kwargs )
954952 provenance_profile = profile .copy ()
955- provenance_profile . pop ( 'nodata' , - 1 )
953+ provenance_profile [ 'nodata' ] = PROVENANCE_ATTRIBUTES [ 'nodata' ]
956954 provenance_profile ['dtype' ] = PROVENANCE_ATTRIBUTES ['data_type' ]
957955
958956 save_as_cog (str (provenance_file ), provenance_array , block_size = block_size , ** provenance_profile )
0 commit comments