microsoft / PlanetaryComputerExamples

Examples of using the Planetary Computer
MIT License
373 stars 183 forks source link

MODIS Nadir BRDF-Adjusted Reflectance (NBAR) Daily explanation #292

Closed paolodep36 closed 4 months ago

paolodep36 commented 4 months ago

Hi i am retrieving images from MODIS Nadir BRDF-Adjusted Reflectance (NBAR) Daily collection. I don't understand how it works because for the city of Milan the output is of 16 items. If it's an aggregation why i have 16 items? which one is correct? I am using the datetime for start and end date. The collection is this modis-43A4-061, the example notebook is not related to this collection.

Thanks

TomAugspurger commented 4 months ago

Can you share an example STAC query / code snippet?

paolodep36 commented 4 months ago

here the code, but i need also to ask what are start_datetime and end_datetime in the properties. I saw that the real date time is in the middle but from start_datetime and end_datetime the count of days is 8 and not 16 as expected by the collection. in this case modis_date is the datetime inside proprierties

        search_modis_nbar = catalog.search(
            collections=["modis-43A4-061"],
            bbox=bbox_of_interest,
            datetime=f"{modis_date}/{modis_date}",
            #query={"eo:cloud_cover": {"lt": cloud_coverage}}
        )
        items_modis_nbar = search_modis_nbar.item_collection()
        print(f"Returned {len(items_modis_nbar)} Modis_nbar Items")
        ref_crs = utm_crs_code

        modis_nbar_files = []
        for i, item in enumerate(items_modis_nbar):
            bands_of_interest = ['Nadir_Reflectance_Band1','Nadir_Reflectance_Band2','Nadir_Reflectance_Band3','Nadir_Reflectance_Band4','Nadir_Reflectance_Band5','Nadir_Reflectance_Band6','Nadir_Reflectance_Band7']
            data = odc.stac.stac_load(
                [item],
                bands=bands_of_interest,
                bbox=bbox_of_interest,
                crs=ref_crs,
                resolution=500,
                fail_on_error=False,
                nodata=0
            )
TomAugspurger commented 4 months ago

what are start_datetime and end_datetime in the properties

I believe that these MODIS products are multi-day mosaics. From https://planetarycomputer.microsoft.com/dataset/modis-43A4-061:

produced daily using 16 days of Terra and Aqua MODIS data at 500 meter (m) resolution

So I think the start & end datetimes are the ends of that 16-day window.

What value are you using for modis_date?

See also https://github.com/microsoft/PlanetaryComputer/issues/335

paolodep36 commented 4 months ago
Screenshot 2024-05-29 at 00 32 00

modis_date refer to the parameter datetime. Tried the solution in the post mentioned and it seems to work and now i retrieve one item per day. I think that the behaviour is that when query={"start_datetime": {"eq": modis_start}, "end_datetime": {"eq": modis_end}, } is not set, odc stack will download all the tiles that contains that date.

TomAugspurger commented 4 months ago

Great, sounds like you got it working so I'll close this.