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

Defensive programming/decrease assumptions: Try/catch for KeyError: 'geo_loc_name' #28

Closed
turbomam opened this issue Apr 5, 2024 · 0 comments · Fixed by #35 · May be fixed by #30
Closed

Defensive programming/decrease assumptions: Try/catch for KeyError: 'geo_loc_name' #28

turbomam opened this issue Apr 5, 2024 · 0 comments · Fixed by #35 · May be fixed by #30
Assignees

Comments

@turbomam
Copy link
Member

turbomam commented Apr 5, 2024

in NEON_soil_metadata/python/neon_soil_metadata_visual_exploration.ipynb

coordinates = set()
geo_locs = set()
dates = set()
for samp in all_results:
    lat_lon = f"{samp['lat_lon']['latitude']},{samp['lat_lon']['longitude']}"
    coordinates.add(lat_lon)
    geo_locs.add(samp["geo_loc_name"]["has_raw_value"])
    dates.add(samp["collection_date"]["has_raw_value"])
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[4], line 10
      8     lat_lon = f"{samp['lat_lon']['latitude']},{samp['lat_lon']['longitude']}"
      9     coordinates.add(lat_lon)
---> 10     geo_locs.add(samp["geo_loc_name"]["has_raw_value"])
     11     dates.add(samp["collection_date"]["has_raw_value"])
     12 print(f"Number of NEON coordinates: {len(coordinates)}")

KeyError: 'geo_loc_name'
@turbomam turbomam self-assigned this Apr 5, 2024
@turbomam turbomam changed the title multiple notebooks have KeyError: 'geo_loc_name' Try/catch for KeyError: 'geo_loc_name' Apr 5, 2024
@turbomam turbomam changed the title Try/catch for KeyError: 'geo_loc_name' Defensive programming/decrease assumptions: Try/catch for KeyError: 'geo_loc_name' Apr 5, 2024
@turbomam turbomam linked a pull request Apr 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment