Skip to content

Commit

Permalink
Merge pull request #1580 from danforthcenter/add-transform-attribute
Browse files Browse the repository at this point in the history
Add geospatial attributes to spectral_data class
  • Loading branch information
nfahlgren authored Aug 14, 2024
2 parents 4b7c85d + 7cce552 commit 0f51190
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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
10 changes: 9 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,13 @@ 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
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
self.geo_crs = geo_crs


class PSII_data:
Expand Down

0 comments on commit 0f51190

Please sign in to comment.