From fe0dc37d88f72e84bbd3510693395df3d7bdfdd3 Mon Sep 17 00:00:00 2001 From: Ariana-B <40238244+Ariana-B@users.noreply.github.com> Date: Wed, 17 Jan 2024 16:53:57 +1100 Subject: [PATCH] tweak list_products to consider load_hints (#1535) * tweak list_products to check for crs and resolution in load_hints * update whats_new * get osgeo/gdal from ghcr --------- Authored-by: Ariana Barzinpour --- datacube/api/core.py | 14 +++++++++++--- docker/Dockerfile | 2 +- docs/about/whats_new.rst | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/datacube/api/core.py b/datacube/api/core.py index 8622c3fb49..f638347f35 100644 --- a/datacube/api/core.py +++ b/datacube/api/core.py @@ -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', @@ -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()] diff --git a/docker/Dockerfile b/docker/Dockerfile index 226df3bf4f..4428fb1351 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/docs/about/whats_new.rst b/docs/about/whats_new.rst index 6b69abcf2e..7488e7d70c 100644 --- a/docs/about/whats_new.rst +++ b/docs/about/whats_new.rst @@ -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) ===========================