-
Notifications
You must be signed in to change notification settings - Fork 11
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 OBIS EOV notebook & update env #220
Merged
Merged
Changes from 6 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4cb12db
Update environment-python_and_r.yml
laurabrenskelle 3e07a61
Add files via upload
laurabrenskelle 109124e
Adding updated OBIS_EOV file
laurabrenskelle a82fe2f
Updating OBIS EOV file
laurabrenskelle 53006a7
Adding NOAA-GIS4Ocean link
laurabrenskelle fc4cd79
Merge branch 'ioos:main' into main
laurabrenskelle 74712a9
Update 2024-09-13-OBIS_EOVs.ipynb
laurabrenskelle ecd7c73
Update environment-python_and_r.yml
laurabrenskelle a42436a
Delete jupyterbook/content/code_gallery/data_analysis_and_visualizati…
laurabrenskelle c81884a
Adding more markdown content
laurabrenskelle e42fa0b
Update 2024-09-13-OBIS_EOVs.ipynb
laurabrenskelle 504637a
Update 2024-09-13-OBIS_EOVs.ipynb
laurabrenskelle 3f6676a
Update 2024-09-13-OBIS_EOVs.ipynb
laurabrenskelle 26e7577
Merge branch 'ioos:main' into main
laurabrenskelle 2097284
Delete jupyterbook/content/code_gallery/data_analysis_and_visualizati…
laurabrenskelle 62ad68e
Uploading the final version
laurabrenskelle 78ab0d7
Adding link to Arctic mangrove GH issue
laurabrenskelle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 179 additions & 0 deletions
179
...content/code_gallery/data_analysis_and_visualization_notebooks/2024-09-13-OBIS_EOVs.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ad98f7a1-d7a1-4a51-a9a2-0da9da7fe042", | ||
"metadata": {}, | ||
"source": [ | ||
"# Using aphiaIDs to download OBIS occurrences for Bio/Eco EOVs\n", | ||
"\n", | ||
"Created: 2024-09-13\n", | ||
"\n", | ||
"The [IOOS Marine Life Data Network](https://ioos.github.io/marine_life_data_network/) has developed a list of aphiaIDs for taxa mentioned in the [GOOS Biology and Ecosystems Variables](https://goosocean.org/what-we-do/framework/essential-ocean-variables/). These lists are meant to assist in querying OBIS to evaluate the abundance and distribution of these taxa. Here is an R notebook of how this might work using mangroves as an example." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "390bf2be-3828-4705-b64b-ed68005ff98b", | ||
"metadata": { | ||
"scrolled": true, | ||
"vscode": { | ||
"languageId": "r" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"library(gh)\n", | ||
"library(readr)\n", | ||
"library(robis)\n", | ||
"library(dplyr)\n", | ||
"library(htmlwidgets)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3089302a", | ||
"metadata": {}, | ||
"source": [ | ||
"First, we will pull the file with the mangrove aphiaIDs from the Marine Life Data Network GitHub repo. **Note**: the acceptedTaxonIds in these files are based on what was up-to-date in the [WoRMS](https://marinespecies.org/) database as of the date this script was written." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "43964864-7fe8-4139-a9d0-2a844161ccd1", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "r" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"mangroves <- read.csv(\"https://raw.githubusercontent.com/ioos/marine_life_data_network/main/eov_taxonomy/mangroves.csv\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "45fa26db", | ||
"metadata": {}, | ||
"source": [ | ||
"Now we will do a bit of cleanup to get a list of aphiaIDs for mangroves so we can run our `robis` query using these as taxon identifiers." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "0bb6ab17-d239-410c-90d0-dcb50359b095", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "r" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"mangroves$ID <- gsub(\"urn:lsid:marinespecies.org:taxname.\", \"\", mangroves$acceptedTaxonId)\n", | ||
"mangroves$ID <- as.numeric(mangroves$ID)\n", | ||
"mangroveIdentifiers <- paste(mangroves$ID, collapse = \", \")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "8a6cefa9", | ||
"metadata": {}, | ||
"source": [ | ||
"Using the taxonIDs from the last step, let's query OBIS for occurrence data for mangroves. This step may take a bit of time to run. When this script was written, there were over 130,000 records for mangroves in OBIS." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "d9aa2697-4ca0-4631-8d77-b0407e7a73b5", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "r" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"mangrove_occ <- robis::occurrence(taxonid = mangroveIdentifiers)\n", | ||
"# let's check how many occurrences we got from OBIS\n", | ||
"nrow(mangrove_occ)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "c837a3ac", | ||
"metadata": {}, | ||
"source": [ | ||
"Now that we have all of our mangrove records from OBIS, we will map the global distribution of records using the `map_leaflet` function found in the `robis` package. With the leaflet functionality, you can zoom into records, click them, and it list the scientific name for that occurrence record." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1ccc9837-4585-4020-852b-cdc6b33ae62d", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "r" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"m <- map_leaflet(mangrove_occ,\n", | ||
" provider_tiles = \"Esri.WorldGrayCanvas\",\n", | ||
" popup = function(x) { x[\"scientificName\"] },\n", | ||
" )\n", | ||
"m" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "202e2512", | ||
"metadata": {}, | ||
"source": [ | ||
"This next step is not required, but if you'd like to save this map to view it outside of R, here's how." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "13a8bc6c-5963-4e4e-acab-f0f6de776045", | ||
"metadata": { | ||
"vscode": { | ||
"languageId": "r" | ||
} | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"\n", | ||
"saveWidget(m, \"mangroveMap.html\", selfcontained = TRUE)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "31bf8a8b", | ||
"metadata": {}, | ||
"source": [ | ||
"For more information and code about how to get EOV data from OBIS, see the [NOAA GIS For The Ocean GitHub project](https://github.com/NOAA-GIS4Ocean/BioEco_EOV)." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "R", | ||
"language": "R", | ||
"name": "ir" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": "r", | ||
"file_extension": ".r", | ||
"mimetype": "text/x-r-source", | ||
"name": "R", | ||
"pygments_lexer": "r", | ||
"version": "4.1.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
257 changes: 257 additions & 0 deletions
257
jupyterbook/content/code_gallery/data_analysis_and_visualization_notebooks/OBIS_EOVs.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this anymore as you are grabbing the csv right from the repo.