Skip to content

Commit

Permalink
tweak list_products to consider load_hints (#1535)
Browse files Browse the repository at this point in the history
* tweak list_products to check for crs and resolution in load_hints

* update whats_new

* get osgeo/gdal from ghcr

---------

Authored-by: Ariana Barzinpour <[email protected]>
  • Loading branch information
Ariana-B authored Jan 17, 2024
1 parent 47f0aca commit fe0dc37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions datacube/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ def list_products(self, with_pandas=True, dataset_count=False):
:return: A table or list of every product in the datacube.
:rtype: pandas.DataFrame or list(dict)
"""
def _get_non_default(product, col):
load_hints = product.load_hints()
if load_hints:
if col == 'crs':
return load_hints.get('output_crs', None)
return load_hints.get(col, None)
return getattr(product.grid_spec, col, None)

# Read properties from each datacube product
cols = [
'name',
Expand All @@ -125,10 +133,10 @@ def list_products(self, with_pandas=True, dataset_count=False):
getattr(pr, col, None)
# if 'default_crs' and 'default_resolution' are not None
# return 'default_crs' and 'default_resolution'
if getattr(pr, col, None) and 'default' not in col
# else try 'grid_spec.crs' and 'grid_spec.resolution'
if getattr(pr, col, None) or 'default' not in col
# else get crs and resolution from load_hints or grid_spec
# as per output_geobox() handling logic
else getattr(pr.grid_spec, col.replace('default_', ''), None)
else _get_non_default(pr, col.replace('default_', ''))
for col in cols]
for pr in self.index.products.get_all()]

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Copyright (c) 2015-2020 ODC Contributors
## SPDX-License-Identifier: Apache-2.0
##
FROM osgeo/gdal:ubuntu-small-latest
FROM ghcr.io/osgeo/gdal:ubuntu-small-latest
ARG V_PG=14
ARG V_PGIS=14-postgis-3

Expand Down
1 change: 1 addition & 0 deletions docs/about/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ v1.8.next
- Update pandas version in docker image to be consistent with conda environment and default to stdlib
timezone instead of pytz when converting timestamps; automatically update copyright years (:pull:`1527`)
- Update github-Dockerhub credential-passing mechanism. (:pull:`1528`)
- Tweak ``list_products`` logic for getting crs and resolution values (:pull:`1535`)

v1.8.17 (8th November 2023)
===========================
Expand Down

0 comments on commit fe0dc37

Please sign in to comment.