@@ -53,7 +53,8 @@ def create_candidate(it, mgrs_id, ref_ts, mgrs_poly, mgrs_crs):
5353 data_coverage = tile_info ["dataCoveragePercentage" ],
5454 ref_ts = ref_ts ,
5555 mgrs_geometry = mgrs_poly ,
56- mgrs_crs = mgrs_crs
56+ mgrs_crs = mgrs_crs ,
57+ stac_item = it
5758 )
5859
5960def search ( client = None , collection = "sentinel-2-l1c" ,
@@ -303,7 +304,8 @@ def fetch_s2_tiles(
303304
304305 from rapida .util .setup_logger import setup_logger
305306 from rapida .components .landuse .search_utils .s2item import Sentinel2Item
306-
307+ from rapida .components .landuse .prediction .landuse import LandusePrediction
308+ from pystac import Item
307309 # logger.setLevel(logging.DEBUG)
308310 logger = setup_logger (level = logging .INFO )
309311 CATALOG_URL = "https://earth-search.aws.element84.com/v1"
@@ -315,7 +317,7 @@ def fetch_s2_tiles(
315317
316318
317319 bbox = 33 , - 1 , 37 , 2
318-
320+ bands = LandusePrediction . required_bands
319321
320322
321323 with Progress () as progress :
@@ -327,26 +329,25 @@ def fetch_s2_tiles(
327329 end_date = "2025-08-30"
328330 results = fetch_s2_tiles (bbox = bbox ,stac_url = CATALOG_URL ,
329331 start_date = start_date , end_date = end_date ,
330- max_cloud_cover = max_cloud_cover , progress = progress ,filter_for_dev = ['36NWF' ])
332+ max_cloud_cover = max_cloud_cover , progress = progress ,filter_for_dev = ['36MZE' ])
333+
331334
332335
333- bands = ['B01' , 'B02' , 'B03' , 'B04' , 'B05' ]
334- bands = ['B03' ]
335336 band_files = {}
336337
337338 for grid , candidates in results .items ():
338339 try :
339340 #logger.info(f'{grid}: {[c for c in candidates]}')
340341 s2i = Sentinel2Item (mgrs_grid = grid , s2_tiles = candidates , workdir = '/tmp' , target_crs = 'ESRI:54034' )
341342 downloaded = s2i .download (bands = bands , progress = progress , force = False )
342- # for k, v in s2i.vrt.items():
343- # pass
344- # with rasterio.open(v) as vsrc:
345- # print(k, tuple(vsrc.bounds))
346- # for bname, bfile in downloaded.items():
347- # if not bname in band_files:
348- # band_files[bname] = []
349- # band_files[bname].append(bfile)
343+ img_paths = [ downloaded [ b ] for b in bands ]
344+ itm = Item . from_dict ( candidates [ 0 ]. stac_item )
345+ landuse_prediction = LandusePrediction ( item = itm )
346+ landuse_prediction . predict ( img_paths = img_paths ,
347+ output_file_path = f'/tmp/landuse_36MZE.tif' ,
348+
349+ progress = progress )
350+
350351
351352
352353 except KeyboardInterrupt :
0 commit comments