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

metadata attribute is missing in calculated spectral indices #1672

Open
HaleySchuhl opened this issue Feb 14, 2025 · 0 comments · May be fixed by #1673
Open

metadata attribute is missing in calculated spectral indices #1672

HaleySchuhl opened this issue Feb 14, 2025 · 0 comments · May be fixed by #1673
Assignees
Labels
bug Bug or potential bug reports enhancement Enhancements to existing features update Updates an existing feature/method
Milestone

Comments

@HaleySchuhl
Copy link
Contributor

Describe the bug
The helper function _package_index is missing the newly added metadata attribute so it's missing in spectral index Objects.

To Reproduce
Steps to reproduce the behavior (including sample data and code really help):

  1. Starting with any geotif, such as this test data.
  2. run the following functions
pcv.spectral_index.ndvi(geotif)
viewer = an.napari_open(img=img.pseudo_rgb)
viewer.add_points()
geo.points_to_geojson(ndvi, viewer, out_path="./points_example.geojson")
  1. See error
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[7], line 1
----> 1 geo.points_to_geojson(ndvi, viewer, out_path="./points_example.geojson")

File [~/Documents/GitHub/plantcv-geospatial/build/__editable__.plantcv_geospatial-0.1.dev315](http://localhost:8888/lab/tree/Projects/geospatial/public_data/~/Documents/GitHub/plantcv-geospatial/build/__editable__.plantcv_geospatial-0.1.dev315)+gbcbcb37-py3-none-any[/plantcv/geospatial/points_to_geojson.py:22](http://localhost:8888/plantcv/geospatial/points_to_geojson.py#line=21), in points_to_geojson(img, viewer, out_path)
     20 # Napari output, points must be reversed
     21 if hasattr(viewer, 'layers'):
---> 22     points = [(img.metadata["transform"]*reversed(i)) for i in viewer.layers["Points"].data]
     23 # Annotate output
     24 elif hasattr(viewer, 'coords'):

File [~/Documents/GitHub/plantcv-geospatial/build/__editable__.plantcv_geospatial-0.1.dev315](http://localhost:8888/lab/tree/Projects/geospatial/public_data/~/Documents/GitHub/plantcv-geospatial/build/__editable__.plantcv_geospatial-0.1.dev315)+gbcbcb37-py3-none-any[/plantcv/geospatial/points_to_geojson.py:22](http://localhost:8888/plantcv/geospatial/points_to_geojson.py#line=21), in <listcomp>(.0)
     20 # Napari output, points must be reversed
     21 if hasattr(viewer, 'layers'):
---> 22     points = [(img.metadata["transform"]*reversed(i)) for i in viewer.layers["Points"].data]
     23 # Annotate output
     24 elif hasattr(viewer, 'coords'):

KeyError: 'transform

Expected behavior
A clear and concise description of what you expected to happen.

Local environment (please complete the following information):

  • OS: [macOS]
  • Environment :[conda]
  • PlantCV Version [4.6]

Additional context
The plantcv-geospatial package will have an analyze.spectral function that requires metadata about the affine in the original geotif in order to use rasterstats.zonal_stats

@HaleySchuhl HaleySchuhl added bug Bug or potential bug reports enhancement Enhancements to existing features update Updates an existing feature/method labels Feb 14, 2025
@HaleySchuhl HaleySchuhl added this to the PlantCV v4.7 milestone Feb 14, 2025
@HaleySchuhl HaleySchuhl self-assigned this Feb 14, 2025
@github-project-automation github-project-automation bot moved this to New Issues in PlantCV4 Feb 14, 2025
@HaleySchuhl HaleySchuhl linked a pull request Feb 14, 2025 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug or potential bug reports enhancement Enhancements to existing features update Updates an existing feature/method
Projects
Status: New Issues
Development

Successfully merging a pull request may close this issue.

1 participant