From e59c63efd65e93f35ab353b42f27419ddf9e6a59 Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:40:46 -0500 Subject: [PATCH 1/9] add attribute "geo_transform" --- plantcv/plantcv/classes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plantcv/plantcv/classes.py b/plantcv/plantcv/classes.py index 76782610c..1cf3f1471 100644 --- a/plantcv/plantcv/classes.py +++ b/plantcv/plantcv/classes.py @@ -298,7 +298,8 @@ class Spectral_data: """PlantCV Hyperspectral data class""" def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_value, d_type, wavelength_dict, - samples, lines, interleave, wavelength_units, array_type, pseudo_rgb, filename, default_bands): + samples, lines, interleave, wavelength_units, array_type, pseudo_rgb, filename, default_bands, + geo_transform): # The actual array/datacube self.array_data = array_data # Min/max available wavelengths (for spectral datacube) @@ -325,6 +326,8 @@ def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_va self.filename = filename # The default band indices needed to make an pseudo_rgb image, if not available then store None self.default_bands = default_bands + # The transformation matrix that converts xy coordinates to georeferenced coordinates + self.transform = geo_transform class PSII_data: From 5b3726da11a6f9c70f0a1b583a73c791b7bc7ba2 Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:36:31 -0500 Subject: [PATCH 2/9] fix typo --- plantcv/plantcv/classes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plantcv/plantcv/classes.py b/plantcv/plantcv/classes.py index 1cf3f1471..d5515b52c 100644 --- a/plantcv/plantcv/classes.py +++ b/plantcv/plantcv/classes.py @@ -327,7 +327,7 @@ def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_va # The default band indices needed to make an pseudo_rgb image, if not available then store None self.default_bands = default_bands # The transformation matrix that converts xy coordinates to georeferenced coordinates - self.transform = geo_transform + self.geo_transform = geo_transform class PSII_data: From e262634c92a140210797fe55c0c8c51885a098ac Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:38:48 -0500 Subject: [PATCH 3/9] add geo_crs as spectral attribute --- plantcv/plantcv/classes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plantcv/plantcv/classes.py b/plantcv/plantcv/classes.py index d5515b52c..aafb6c744 100644 --- a/plantcv/plantcv/classes.py +++ b/plantcv/plantcv/classes.py @@ -9,6 +9,7 @@ from math import floor import altair as alt import pandas as pd +import affine.Affine as Affine class Params: @@ -299,7 +300,7 @@ class Spectral_data: def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_value, d_type, wavelength_dict, samples, lines, interleave, wavelength_units, array_type, pseudo_rgb, filename, default_bands, - geo_transform): + geo_transform=None, geo_crs=None): # The actual array/datacube self.array_data = array_data # Min/max available wavelengths (for spectral datacube) @@ -327,7 +328,10 @@ def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_va # The default band indices needed to make an pseudo_rgb image, if not available then store None self.default_bands = default_bands # The transformation matrix that converts xy coordinates to georeferenced coordinates - self.geo_transform = geo_transform + if not geo_transform: + self.geo_transform = Affine.identity() + # The coordinate system of a georeferenced image + self.geo_crs = geo_crs class PSII_data: From 29ab2ba1bd51cafa0fdd4aeea11f1a6b5329b246 Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:42:56 -0500 Subject: [PATCH 4/9] change affine import --- plantcv/plantcv/classes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plantcv/plantcv/classes.py b/plantcv/plantcv/classes.py index aafb6c744..56e2d3955 100644 --- a/plantcv/plantcv/classes.py +++ b/plantcv/plantcv/classes.py @@ -9,7 +9,7 @@ from math import floor import altair as alt import pandas as pd -import affine.Affine as Affine +import affine class Params: @@ -329,7 +329,7 @@ def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_va self.default_bands = default_bands # The transformation matrix that converts xy coordinates to georeferenced coordinates if not geo_transform: - self.geo_transform = Affine.identity() + self.geo_transform = affine.Affine.identity() # The coordinate system of a georeferenced image self.geo_crs = geo_crs From 44ccbe4b6dfa9cbdde666e7b41fd24d4a50380a5 Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:00:40 -0500 Subject: [PATCH 5/9] try adding affine to environment --- environment.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/environment.yml b/environment.yml index b5ccb419a..dfda6a3f8 100644 --- a/environment.yml +++ b/environment.yml @@ -25,6 +25,7 @@ dependencies: - altair - vl-convert-python - git + - affine channels: - conda-forge From d17497760f05f329856a7c6a160a19ff2c3195cb Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:24:44 -0500 Subject: [PATCH 6/9] remove affine from environment --- environment.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/environment.yml b/environment.yml index dfda6a3f8..b5ccb419a 100644 --- a/environment.yml +++ b/environment.yml @@ -25,7 +25,6 @@ dependencies: - altair - vl-convert-python - git - - affine channels: - conda-forge From ff7b4202d953644844cbfac16a7790199b3ea9f7 Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:04:20 -0500 Subject: [PATCH 7/9] changed default format for geo_transform spectral attribute --- plantcv/plantcv/classes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plantcv/plantcv/classes.py b/plantcv/plantcv/classes.py index 56e2d3955..67355d3a3 100644 --- a/plantcv/plantcv/classes.py +++ b/plantcv/plantcv/classes.py @@ -9,7 +9,6 @@ from math import floor import altair as alt import pandas as pd -import affine class Params: @@ -328,8 +327,9 @@ def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_va # The default band indices needed to make an pseudo_rgb image, if not available then store None self.default_bands = default_bands # The transformation matrix that converts xy coordinates to georeferenced coordinates + # Default is the input list for affine.Affine to make an identity matrix if not geo_transform: - self.geo_transform = affine.Affine.identity() + self.geo_transform = (1.0, 0.0, 0.0, 0.0, 1.0, 0.0) # The coordinate system of a georeferenced image self.geo_crs = geo_crs From aaecbe0c01de720727fa9b43c79a6de430081408 Mon Sep 17 00:00:00 2001 From: KeelyBrown <156026125+k034b363@users.noreply.github.com> Date: Tue, 13 Aug 2024 16:32:34 -0500 Subject: [PATCH 8/9] Add new spectral_data attr. to docs --- docs/Spectral_data.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/Spectral_data.md b/docs/Spectral_data.md index ac99f45bc..84aebfb0b 100644 --- a/docs/Spectral_data.md +++ b/docs/Spectral_data.md @@ -38,6 +38,10 @@ Attributes are accessed as spectral_data_instance.*attribute*. **filename**: The filename where the data originated from +**geo_transform**: The affine transformation matrix used to convert from an xy coordinate system to a georeferenced coordinate system. Default is the input list used by the affine package to create an identity matrix. + +**geo_crs**: The original coordinate system of a georeferenced image. Default is "None". + ### Example PlantCV functions from the hyperspectral sub-package use `Spectral_data` implicitly. From 7cce552b78ed7be95db79210f33cf4a3f2ca7190 Mon Sep 17 00:00:00 2001 From: Noah Fahlgren Date: Tue, 13 Aug 2024 22:02:10 -0500 Subject: [PATCH 9/9] Set class attribute from input before applying default value --- plantcv/plantcv/classes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plantcv/plantcv/classes.py b/plantcv/plantcv/classes.py index 67355d3a3..c955da368 100644 --- a/plantcv/plantcv/classes.py +++ b/plantcv/plantcv/classes.py @@ -328,6 +328,7 @@ def __init__(self, array_data, max_wavelength, min_wavelength, max_value, min_va self.default_bands = default_bands # The transformation matrix that converts xy coordinates to georeferenced coordinates # Default is the input list for affine.Affine to make an identity matrix + self.geo_transform = geo_transform if not geo_transform: self.geo_transform = (1.0, 0.0, 0.0, 0.0, 1.0, 0.0) # The coordinate system of a georeferenced image