From 76e40c0d9b70a677ade7a48824ada6775ddb7512 Mon Sep 17 00:00:00 2001 From: kamangir Date: Sun, 8 Dec 2024 19:26:41 -0800 Subject: [PATCH] @datacube crop refactors - kamangir/bolt#746 --- README.md | 2 +- blue_geo/.abcli/datacube/crop.sh | 8 ++++---- blue_geo/.abcli/gdal/get_crs.sh | 5 +++++ blue_geo/.abcli/tests/gdal_get_crs.sh | 12 ++++++++++++ blue_geo/.abcli/tests/help.sh | 3 +++ blue_geo/__init__.py | 2 +- blue_geo/help/gdal.py | 16 ++++++++++++++++ blue_geo/watch/README.md | 22 +++++++++++----------- 8 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 blue_geo/.abcli/gdal/get_crs.sh create mode 100644 blue_geo/.abcli/tests/gdal_get_crs.sh diff --git a/README.md b/README.md index 322ad612..c446a795 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ pip install blue-geo [![pylint](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pylint.yml) [![pytest](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/pytest.yml) [![bashtest](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml/badge.svg)](https://github.com/kamangir/blue-geo/actions/workflows/bashtest.yml) [![PyPI version](https://img.shields.io/pypi/v/blue-geo.svg)](https://pypi.org/project/blue-geo/) [![PyPI - Downloads](https://img.shields.io/pypi/dd/blue-geo)](https://pypistats.org/packages/blue-geo) -built by 🌀 [`blue_options-4.173.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.836.1`](https://github.com/kamangir/blue-geo). +built by 🌀 [`blue_options-4.173.1`](https://github.com/kamangir/awesome-bash-cli), based on 🌐 [`blue_geo-4.837.1`](https://github.com/kamangir/blue-geo). diff --git a/blue_geo/.abcli/datacube/crop.sh b/blue_geo/.abcli/datacube/crop.sh index 2e169843..f051b87a 100644 --- a/blue_geo/.abcli/datacube/crop.sh +++ b/blue_geo/.abcli/datacube/crop.sh @@ -24,7 +24,7 @@ function blue_geo_datacube_crop() { $object_name \ $cropped_datacube_id - local crs=$(gdalsrsinfo -o epsg $cutline) + local crs=$(blue_geo_gdal_get_crs $cutline) abcli_log "cutline crs: $crs" local list_of_files=$(blue_geo_datacube_list $datacube_id \ @@ -38,7 +38,7 @@ function blue_geo_datacube_crop() { for filename in $list_of_files; do source_filename=$ABCLI_OBJECT_ROOT/$datacube_id/$filename - local source_filename_crs=$(gdalsrsinfo -o epsg $source_filename) + local source_filename_crs=$(blue_geo_gdal_get_crs $source_filename) abcli_log "cropping $filename @ $source_filename_crs ..." destination_filename=$ABCLI_OBJECT_ROOT/$cropped_datacube_id/$filename @@ -53,8 +53,8 @@ function blue_geo_datacube_crop() { $source_filename \ $destination_filename - local destination_filename_crs=$(gdalsrsinfo -o epsg $destination_filename) - abcli_log "output crs: $destination_filename - expected $crs." + local destination_filename_crs=$(blue_geo_gdal_get_crs $destination_filename) + abcli_log "output crs: $destination_filename_crs - expected $crs." done return 0 diff --git a/blue_geo/.abcli/gdal/get_crs.sh b/blue_geo/.abcli/gdal/get_crs.sh new file mode 100644 index 00000000..e1597423 --- /dev/null +++ b/blue_geo/.abcli/gdal/get_crs.sh @@ -0,0 +1,5 @@ +#! /usr/bin/env bash + +function blue_geo_gdal_get_crs() { + gdalsrsinfo -o epsg ${1:-void} | tr -d '\n' +} diff --git a/blue_geo/.abcli/tests/gdal_get_crs.sh b/blue_geo/.abcli/tests/gdal_get_crs.sh new file mode 100644 index 00000000..cf8a70df --- /dev/null +++ b/blue_geo/.abcli/tests/gdal_get_crs.sh @@ -0,0 +1,12 @@ +#! /usr/bin/env bash + +function test_blue_geo_gdal_get_crs() { + local options=$1 + + local object_name=$BLUE_GEO_WATCH_TARGET_LIST + abcli_download - $object_name + + local crs=$(blue_geo_gdal_get_crs $ABCLI_OBJECT_ROOT/$object_name/target/shape.geojson) + + abcli_assert "$crs" EPSG:4326 +} diff --git a/blue_geo/.abcli/tests/help.sh b/blue_geo/.abcli/tests/help.sh index 8e81febb..2534b3f2 100644 --- a/blue_geo/.abcli/tests/help.sh +++ b/blue_geo/.abcli/tests/help.sh @@ -24,6 +24,9 @@ function test_@geo_help() { "@geo datacube list" \ \ "@geo gdal" \ + "@geo gdal get_crs" \ + "@geo gdal install" \ + "@geo gdal version" \ \ "@geo ingest" \ \ diff --git a/blue_geo/__init__.py b/blue_geo/__init__.py index e4586781..a8a3a09f 100644 --- a/blue_geo/__init__.py +++ b/blue_geo/__init__.py @@ -9,7 +9,7 @@ DESCRIPTION = f"{ICON} AI for a Blue Planet." -VERSION = "4.836.1" +VERSION = "4.837.1" REPO_NAME = "blue-geo" diff --git a/blue_geo/help/gdal.py b/blue_geo/help/gdal.py index 1f1ef51a..3e6bd2d9 100644 --- a/blue_geo/help/gdal.py +++ b/blue_geo/help/gdal.py @@ -3,6 +3,21 @@ from blue_options.terminal import show_usage +def help_get_crs( + tokens: List[str], + mono: bool, +) -> str: + return show_usage( + [ + "@gdal", + "get_crs", + "", + ], + "get crs.", + mono=mono, + ) + + def help_install( tokens: List[str], mono: bool, @@ -32,6 +47,7 @@ def help_version( help_functions = { + "get_crs": help_get_crs, "install": help_install, "version": help_version, } diff --git a/blue_geo/watch/README.md b/blue_geo/watch/README.md index 6cb81d80..5aae0825 100644 --- a/blue_geo/watch/README.md +++ b/blue_geo/watch/README.md @@ -139,7 +139,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Cache-Creek-2x-wider-2024-11-05/geo-watch-Cache-Creek-2x-wider-2024-11-05-4X.gif?raw=true&random=vUKC0eYPFk139qAb) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Cache-Creek-2x-wider-2024-11-05/geo-watch-Cache-Creek-2x-wider-2024-11-05-4X.gif?raw=true&random=uh3n2WZ9vNvGaK98)
@@ -155,7 +155,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-DrugSuperLab-2024-11-19-13954/geo-watch-DrugSuperLab-2024-11-19-13954-4X.gif?raw=true&random=iL4nSDuYXZxJVHvp) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-DrugSuperLab-2024-11-19-13954/geo-watch-DrugSuperLab-2024-11-19-13954-4X.gif?raw=true&random=naHgEGUXBnducN6r)
@@ -170,7 +170,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Fagradalsfjall-a/geo-watch-2024-09-04-Fagradalsfjall-a-2X.gif?raw=true&random=1UtkDbSHwtD3DXMw) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Fagradalsfjall-a/geo-watch-2024-09-04-Fagradalsfjall-a-2X.gif?raw=true&random=bhbT3A3RNmVEpMTO)
@@ -183,7 +183,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Jasper-2024-11-03/geo-watch-Jasper-2024-11-03-2X.gif?raw=true&random=4bWns7IFk0bBoPVm) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Jasper-2024-11-03/geo-watch-Jasper-2024-11-03-2X.gif?raw=true&random=ebCwHJ2H1aTO6iTu)
@@ -198,7 +198,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-10-27-16-17-36-12059/geo-watch-2024-10-27-16-17-36-12059-4X.gif?raw=true&random=lnMcHhS3NmrWxQQD) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-10-27-16-17-36-12059/geo-watch-2024-10-27-16-17-36-12059-4X.gif?raw=true&random=gS14DoV70KrcMZrq)
@@ -216,7 +216,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Mount-Etna-a/geo-watch-2024-09-04-Mount-Etna-a-2X.gif?raw=true&random=UK9wmEF4RgP4Kr3x) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-Mount-Etna-a/geo-watch-2024-09-04-Mount-Etna-a-2X.gif?raw=true&random=VEaqmZhe6MpdH77K)
@@ -229,7 +229,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Silver-Peak-2024-10-12-a/geo-watch-Silver-Peak-2024-10-12-a-4X.gif?raw=true&random=EO7nsfdNTYv9GueN) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Silver-Peak-2024-10-12-a/geo-watch-Silver-Peak-2024-10-12-a-4X.gif?raw=true&random=zsrhhzw1WUSJbxTH)
@@ -243,7 +243,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-bellingcat-2024-09-27-nagorno-karabakh-6X-2024-10-06-a/geo-watch-bellingcat-2024-09-27-nagorno-karabakh-6X-2024-10-06-a-4X.gif?raw=true&random=LJuGrnetR81Lu1ep) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-bellingcat-2024-09-27-nagorno-karabakh-6X-2024-10-06-a/geo-watch-bellingcat-2024-09-27-nagorno-karabakh-6X-2024-10-06-a-4X.gif?raw=true&random=kMVnVdOm9RAR8UcL)
@@ -259,7 +259,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-burning-man-2024-a/geo-watch-2024-09-04-burning-man-2024-a-2X.gif?raw=true&random=CHNdZrVocFdWEOpd) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-2024-09-04-burning-man-2024-a/geo-watch-2024-09-04-burning-man-2024-a-2X.gif?raw=true&random=2ZYCFMqFFVVuAhG6)
@@ -271,7 +271,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Chilcotin-2024-11-03/geo-watch-Chilcotin-2024-11-03-4X.gif?raw=true&random=4su2oALMCbP6M8bM) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-Chilcotin-2024-11-03/geo-watch-Chilcotin-2024-11-03-4X.gif?raw=true&random=FT9AW7JRbN0JWKJu)
@@ -290,7 +290,7 @@ watch the planet's story unfold.
🌐 -![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-elkhema-2024-2024-10-05-a-b/geo-watch-elkhema-2024-2024-10-05-a-b-4X.gif?raw=true&random=D7vhvBzFAu6enLZg) +![image](https://kamangir-public.s3.ca-central-1.amazonaws.com/geo-watch-elkhema-2024-2024-10-05-a-b/geo-watch-elkhema-2024-2024-10-05-a-b-4X.gif?raw=true&random=opYiZGPC0887mvQU)