Skip to main content

I have written a script based on this tutorial that access BYOC collection and creates GeoDataframe with data about all the tiles.


This is how I do this:


byoc = SentinelHubBYOC(config=config)  
my_collection = byoc.get_collection(instance_id)
col_name=my_collection['name']
tile_iterator = byoc.iter_tiles(my_collection)

collect_tiles=[]
for i in np.arange(0,num_imgs,1):
collect_tiles.append(ByocTile.from_dict(next(tile_iterator)))

gdf = gpd.GeoDataFrame(collect_tiles,
geometry=[t.cover_geometry.transform(CRS.WGS84).geometry for t in collect_tiles], crs="epsg:4326")
gdf_1=gdf.reset_index()

My problem here is that I need to know the exact number of tiles I have in my collection for this script to work (the variable “num_imgs”) . My question is, is there any wat that I can get my BYOC size within my code without use it as a known parameter?


Thanks in advanced 🙂

You create this num_imgs only for iterating right? Instead of doing it like that you can iterate over the tile iterator directly:


for tile in tile_iterator:
collect_tiles.append(ByocTile.from_dict(tile))

The iterator will run until there’s no more tiles in the collection


Reply