Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add geospatial attributes to spectral_data class #1580

Merged
merged 9 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/Spectral_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion plantcv/plantcv/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=None, geo_crs=None):
# The actual array/datacube
self.array_data = array_data
# Min/max available wavelengths (for spectral datacube)
Expand All @@ -325,6 +326,12 @@ 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
# Default is the input list for affine.Affine to make an identity matrix
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
self.geo_crs = geo_crs


class PSII_data:
Expand Down