Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Datacube.load should better support CRS object and atemporal products #807

Closed
benjimin opened this issue Nov 6, 2019 · 5 comments
Closed

Comments

@benjimin
Copy link
Contributor

benjimin commented Nov 6, 2019

Support for atemporal products (such as a static DEM) should be improved, particularly in Datacube.load as in this example where the like parameter behaves unexpectedly. Also, the same function should fully support the datacube.utils.geometry.CRS object, rather than requiring e.g. WKT conversion for some fields and not others.

Obvious use case: extract any limited xarray from a datacube, then seek to combine with DEM.

Setup:

lat, lon, e = -35.09407, 150.80426, 0.01
import datacube
dc = datacube.Datacube()
x = dc.load(product='ls8_nbart_albers', time=('2019-06', '2019-07'), 
            lat=(lat-e,lat+e), lon=(lon-e,lon+e))

Problem 1: This should return data:

>>> dc.load(product='dsm1sv10', like=x)
<xarray.Dataset>
Dimensions:  ()
Data variables:
    *empty*

Problem 2: This should completely work:

>>> cr = lambda coord: (coord.data.min(), coord.data.max())
>>> dc.load(product='dsm1sv10', x=cr(x.x), y=cr(x.y), 
...         crs=x.crs, output_crs=x.crs, resolution=(25,-25))
TypeError: unhashable type: 'CRS'

The combination of the problems: the following does work and is confusingly cumbersome:

>>> dc.load(product='dsm1sv10', x=cr(x.x), y=cr(x.y), 
...         crs=x.crs.wkt, output_crs=x.crs, resolution=(25,-25))
<xarray.Dataset>
Dimensions:    (time: 1, x: 86, y: 100)
...
Attributes:
    crs:      EPSG:3577
@Kirill888
Copy link
Member

@benjimin open time ranges is what needed in this case. The reason why like doesn't work in this case is that

  1. It injects time=() into a query, because input has time axis
  2. We do not have open ended ranges so we can't mark "atemporal" datasets with time=(0, +inf)

Work around for your case is to remove time dimension when using like= parameter:

>>> dc.load(product='dsm1sv10', like=x.isel(time=0))

@Kirill888
Copy link
Member

Also see #808, when merged you'll be able to do:

>>> dc.load(product='dsm1sv10', like=x.geobox)

@benjimin
Copy link
Contributor Author

Yep, query by geobox is helpful. (Had totally forgotten I'd offered a PR for that years ago.)

Still, crs argument of Datacube.load should tolerate a datacube CRS object, don't you think?

@Kirill888
Copy link
Member

@benjimin I missed that part, can you make a new issue for that, certainly output_crs= can/expects CRS object, I assumed same applied to crs=

@Kirill888
Copy link
Member

So the CRS part is fixed by #812. Hopefully #808 helps with atemporal products. And since we already have #183, I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants