def loadAll(products, key, bands): ds = [] for product in products: dc = datacube.Datacube() gw = GridWorkflow(dc.index, product=product) # Get the list of tiles (one for each time point) for this product tile_list = gw.list_tiles(product=product, cell_index=key, group_by='solar_day') dc.close() # Load all tiles for tile_index, tile in tile_list.items(): dataset = gw.load(tile, measurements=bands) if (dataset.variables): ds.append(dataset) return ds
def loadByTile(products, key, min_y, max_y, min_x, max_x, bands): ds = [] for product in products: dc = datacube.Datacube() # Create the GridWorkflow object for this product curr_gw = GridWorkflow(dc.index, product=product) # Get the list of tiles (one for each time point) for this product tile_list = curr_gw.list_tiles(product=product, cell_index=key, group_by='solar_day') dc.close() # Retrieve the specified pixel for each tile in the list for tile_index, tile in tile_list.items(): dataset = curr_gw.load(tile[0:1, min_y:max_y, min_x:max_x], measurements=bands) if (dataset.variables): ds.append(dataset) return ds
# Create GridWorkflow object so we can work with tiles gw = GridWorkflow(dc.index, product=sref_products[-1]) # List to store the three datasets (LS5, LS7, LS8) sref_ds = [] # The key represents which tile we are using key = (5, -28) # Need to fetch the tiles for each product seperately for product in sref_products: gw = GridWorkflow(dc.index, product=product) # Get the list of tiles (one for each time point) for this product tile_list = gw.list_tiles(product=product, cell_index=key) # Load all tiles for tile_index, tile in tile_list.items(): dataset = gw.load(tile[0:1, 400:401, 0:1], measurements=['red', 'nir', 'blue', 'green']) # 200ish/400ish if (dataset.variables): sref_ds.append(dataset) # Close datacube connection to database dc.close() # Concatenate the three datasets sref = xr.concat(sref_ds, dim='time')