2

I recently updated to version 1.8.6 of OpenDataCube and have issue with dc.load function. For example when running:

ds = dc.load(product=product,
             longitude=(min_lon, max_lon),
             latitude=(min_lat, max_lat),
             time=year,
             measurements=measurements,
             crs="EPSG:4326",
             output_crs="EPSG:32632",
             resolution=(-30, 30))
print(ds)

I get an empty dataset.

<xarray.Dataset>
Dimensions:  ()
Data variables:
    *empty*

If I comment the dimensions parameters (I increased the resolution to fasten loading):

ds = dc.load(product=product,
             # longitude=(min_lon, max_lon),
             # latitude=(min_lat, max_lat),
             time=year,
             measurements=measurements,
             # crs="EPSG:4326",
             output_crs="EPSG:32632",
             resolution=(-300, 300))
print(ds)

I get:

<xarray.Dataset>
Dimensions:      (time: 2, y: 744, x: 810)
Coordinates:
  * time         (time) datetime64[ns] 1996-11-29T09:37:58 1996-12-31T09:39:29
  * y            (y) float64 5.364e+06 5.364e+06 ... 5.141e+06 5.141e+06
  * x            (x) float64 3.088e+05 3.092e+05 ... 5.512e+05 5.516e+05
    spatial_ref  int32 32632
Data variables:
    SR_B2        (time, y, x) uint16 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
    SR_B3        (time, y, x) uint16 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
    SR_B4        (time, y, x) uint16 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
Attributes:
    crs:           EPSG:32632
    grid_mapping:  spatial_ref

To make sure I am using dimensions within the area containing data I run:

min_x = float(min(ds.x)) + (float(max(ds.x)) - float(min(ds.x))) / 3
max_x = float(min(ds.x)) + 2 * (float(max(ds.x)) - float(min(ds.x))) / 3
min_y = float(min(ds.y)) + (float(max(ds.y)) - float(min(ds.y))) / 3
max_y = float(min(ds.y)) + 2 * (float(max(ds.y)) - float(min(ds.y))) / 3

ds = dc.load(product=product,
             x=(min_x, max_x),
             y=(min_y, max_y),
             time=year,
             measurements=measurements,
             crs=ds.crs,
             output_crs="EPSG:32632",
             resolution=(-30, 30))
print(ds)

The returned dataset is still empty:

<xarray.Dataset>
Dimensions:  ()
Data variables:
    *empty*

You can find in https://owncloud.unepgrid.ch/index.php/s/4QbKU02XnqDH9nY the files I am using to get this result:

  • dc_data folder contains 3 Landsat tm scenes acquired via m2m api
  • lsc2-products.yaml is the product description file
  • load_bug_demo.ipynb is a demo notebook

The demo notebook also allows to export RGB bands from the firstsuccesfully loaded dataset as geotiff as well as a geojson with the dimensions used in the last load attempt. Then user can check they properly overlay with an external software.

1
  • What happens if you add longitude and latitude but don't add crs?
    – Alex Leith
    May 16, 2022 at 6:20

1 Answer 1

1

I just found the answer, thanks to Paul Haesler for highlighting it to me (on Slack). I inverted lat-lon in decimal degrees in my preparation script. enter image description here I guess this is the metadata used by dc.load function when adding lat-lon parameters, and this info is not used without geographic parameter. Explaining why I would get a proper dataset when loading the full datacube, and get nothing when specifying (inverted) lat-lon.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .