Get number of images in BYOC without counting

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)
tile_iterator = byoc.iter_tiles(my_collection)

for i in np.arange(0,num_imgs,1):

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

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 :slight_smile:

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:

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

1 Like