opendatacube / odc-stac

Load STAC items into xarray Datasets.
Apache License 2.0
139 stars 20 forks source link

Loading modis images gives an empty zone in final datacube #128

Closed Git-Yon closed 11 months ago

Git-Yon commented 11 months ago

Hello,

I use odc.stac on MODIS images to recover large areas. My problem is the following, when recuperating images with the code below, I don' understand the resulting output image with an "empty zone" in the middle of the image that contains no NaN Value. I'm sending you the images that show this empty zone at the end.

##Import

import odc.stac              #  version : 0.3.2
import planetary_computer    #  version : 0.4.9
import pystac_client         #  version : 0.6.0
import pystac                #  version : 1.7.0
import matplotlib.pyplot as plt
import warnings                        

## parameters
time_range = "2017-01-01/2017-01-10"
bbox = [0.772335646171, 6.19, 3.83, 12.4157]

## Catalog

catalog = pystac_client.Client.open(
    "https://planetarycomputer.microsoft.com/api/stac/v1",
    modifier=planetary_computer.sign_inplace,)

search = catalog.search(collections=["modis-13Q1-061"], 
                        bbox=bbox,
                        datetime=time_range)

items = search.get_all_items()
items_dict = dict()
for i in range(len(items)):
    items_dict[i] = items[i]

##Loading

data = odc.stac.load(
    items_dict.values(),
    crs="EPSG:3857",
    bbox=bbox,
    resolution=250, ## per pixel
    bands=["250m_16_days_NDVI","250m_16_days_pixel_reliability","250m_16_days_view_zenith_angle"]
)

##Plot to show

tamp_bbox_base = data.isel(time=0)
variable = tamp_bbox_base['250m_16_days_NDVI']
plt.imshow(variable)
plt.show()
variable

Thinking that this was due to the area being too large and with too many dates, I tried to take just 1 image, but the problem persisted. I then tried to split my bbox into different small bboxes, unfortunately, the problem is still there. The only difference is that in this case, the "empty zone" becomes smaller, but it never disappears.

Using rasterio to download the tiles that contain my zone I don't have this problem, so I think it may be due to ODC.stac. I'd like to point out that we've tested different computers/servers and the problem persists. I've also tested several environments.

Note that the CRS is a custom when we check in rasterio, if i dont select a CRS or resolution i got the error about the "auto_guess". But I don't know if this has anything to do with it. crs_custom

1 bbox for my area

all_in_one_bbox

10 bbox for my area

bbox_divide_in_10

20 bbox for my area

bbox_divide_in_20

Kirill888 commented 11 months ago

@Git-Yon odc-stac==0.3.2 is quite old, can you please try with the current version odc-stac==0.3.7.

Kirill888 commented 11 months ago

That collection is missing nodata marker, adding odc.stac.load(.., nodata=-3000) fixes the problem for me.

Git-Yon commented 11 months ago

It's working for me too thanks !