From 71a4d0d8f77a5a454ff9fd472ce2727a5fc8e22a Mon Sep 17 00:00:00 2001 From: Elliott Imhoff Date: Tue, 28 Apr 2026 11:45:36 -0500 Subject: [PATCH 1/5] Parse altitude source --- imgparse/cli.py | 15 +++++++++++++++ imgparse/parser.py | 9 +++++++++ imgparse/xmp_tags.py | 2 ++ pyproject.toml | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/imgparse/cli.py b/imgparse/cli.py index 3f3718b..0f321ae 100644 --- a/imgparse/cli.py +++ b/imgparse/cli.py @@ -250,3 +250,18 @@ def create_metadata_csv(imagery_path: str) -> None: # noqa: D301 ) logger.info("Metadata csv saved at: %s", metadata_csv) + + +@cli.command() +@click.argument("imagery_path", required=True) +def get_xmp(imagery_path: str) -> None: + """Parse the raw XMP metadata.""" + for key, value in MetadataParser(imagery_path).xmp_data.items(): + print(f"{key}: {value}") + + +@cli.command() +@click.argument("imagery_path") +def get_altitude_source(imagery_path: str) -> None: + """Parse the source of the altitude data.""" + print("Altitude source:", MetadataParser(imagery_path).altitude_source()) diff --git a/imgparse/parser.py b/imgparse/parser.py index 2678b0a..81d2c16 100644 --- a/imgparse/parser.py +++ b/imgparse/parser.py @@ -475,6 +475,15 @@ def gsd( raise ValueError("Parsed gsd is less than or equal to 0") return alt / focal_length + + def altitude_source(self) -> str: + """Get the source of the altitude data.""" + try: + return str(self.xmp_data[self.xmp_tags.ALTITUDE_SOURCE]) + except KeyError: + raise ParsingError( + "Couldn't parse altitude source. Sensor might not be supported" + ) def autoexposure(self) -> float: """ diff --git a/imgparse/xmp_tags.py b/imgparse/xmp_tags.py index b168d76..8b3f219 100644 --- a/imgparse/xmp_tags.py +++ b/imgparse/xmp_tags.py @@ -32,6 +32,7 @@ class XMPTags: X_ACCURACY_M: str = "" Y_ACCURACY_M: str = "" Z_ACCURACY_M: str = "" + ALTITUDE_SOURCE: str = "" class SenteraTags(XMPTags): @@ -53,6 +54,7 @@ class SenteraTags(XMPTags): X_ACCURACY_M: str = "Camera:GPSXYAccuracy" Y_ACCURACY_M: str = "Camera:GPSXYAccuracy" Z_ACCURACY_M: str = "Camera:GPSZAccuracy" + ALTITUDE_SOURCE: str = "Sentera:AboveGroundAltitudeSource" class DJITags(XMPTags): diff --git a/pyproject.toml b/pyproject.toml index e6cec92..e4f9561 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "imgparse" -version = "2.0.11" +version = "2.0.12" description = "Python image-metadata-parser utilities" authors = [] include = [ From 6b0d6485e1c2c2ce972b116c5c07a4d8ec1242c3 Mon Sep 17 00:00:00 2001 From: Elliott Imhoff Date: Tue, 28 Apr 2026 11:46:33 -0500 Subject: [PATCH 2/5] Pre-commit --- .pre-commit-config.yaml | 2 -- imgparse/parser.py | 2 +- imgparse/s3.py | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 908e416..62dec0c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,8 +16,6 @@ repos: additional_dependencies: [ 'flake8-docstrings', 'flake8-builtins', - 'flake8-rst-docstrings', - 'pygments', 'pep8-naming' ] - repo: local diff --git a/imgparse/parser.py b/imgparse/parser.py index 81d2c16..49e3796 100644 --- a/imgparse/parser.py +++ b/imgparse/parser.py @@ -475,7 +475,7 @@ def gsd( raise ValueError("Parsed gsd is less than or equal to 0") return alt / focal_length - + def altitude_source(self) -> str: """Get the source of the altitude data.""" try: diff --git a/imgparse/s3.py b/imgparse/s3.py index 8120a89..eab69a4 100644 --- a/imgparse/s3.py +++ b/imgparse/s3.py @@ -25,7 +25,7 @@ def from_uri(cls, image_path: str) -> S3PathStub: from s3path import S3Path except ImportError: # Use the stub class as a fallback - S3Path = S3PathStub # type: ignore + S3Path = S3PathStub def s3_resource(role_arn: str | None = None) -> S3ServiceResource: From a092aad29f57202d174107bafbc4076d4d62ce6c Mon Sep 17 00:00:00 2001 From: Elliott Imhoff Date: Tue, 28 Apr 2026 11:49:58 -0500 Subject: [PATCH 3/5] Update pre-commit --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62dec0c..1ad4abb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,15 +1,15 @@ repos: - repo: https://github.com/pycqa/isort - rev: 7.0.0 + rev: 9.0.0a3 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/ambv/black - rev: 24.4.0 + rev: 26.3.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: '7.0.0' + rev: '7.3.0' hooks: - id: flake8 exclude: (tests) From 9cfdc35dc7fcb78822ed93f3ba4fd042c17bc51c Mon Sep 17 00:00:00 2001 From: Elliott Imhoff Date: Tue, 28 Apr 2026 12:03:34 -0500 Subject: [PATCH 4/5] Fix pre-commit --- imgparse/s3.py | 3 +-- mypy.ini | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/imgparse/s3.py b/imgparse/s3.py index eab69a4..36fc108 100644 --- a/imgparse/s3.py +++ b/imgparse/s3.py @@ -24,8 +24,7 @@ def from_uri(cls, image_path: str) -> S3PathStub: try: from s3path import S3Path except ImportError: - # Use the stub class as a fallback - S3Path = S3PathStub + S3Path = S3PathStub # type: ignore def s3_resource(role_arn: str | None = None) -> S3ServiceResource: diff --git a/mypy.ini b/mypy.ini index 99a46de..a6b71af 100644 --- a/mypy.ini +++ b/mypy.ini @@ -4,3 +4,4 @@ namespace_packages = True explicit_package_bases = True scripts_are_modules = True strict = True +warn_unused_ignores = False From 2cf4605ad36301156addc71c723752c923bdd1d8 Mon Sep 17 00:00:00 2001 From: Elliott Imhoff Date: Tue, 28 Apr 2026 12:52:58 -0500 Subject: [PATCH 5/5] Diff --- imgparse/s3.py | 1 + 1 file changed, 1 insertion(+) diff --git a/imgparse/s3.py b/imgparse/s3.py index 36fc108..8120a89 100644 --- a/imgparse/s3.py +++ b/imgparse/s3.py @@ -24,6 +24,7 @@ def from_uri(cls, image_path: str) -> S3PathStub: try: from s3path import S3Path except ImportError: + # Use the stub class as a fallback S3Path = S3PathStub # type: ignore