This year, I want to start using my Seek (iNaturalist) app more to help with species identification. I thought it would be fun to map out my observations.
Click the numbers on the map to get pulled into the specific species observations. Each taxon type is indicated by a different symbol:
Plantae Insecta Mammalia Reptilia Mollusca Fungi Aves Animalia
Click on a singular point to see more information on the observation!
Code
# Specify username and observations URLusername <-"shmuir"url <-paste0("https://api.inaturalist.org/v1/observations?user_id=", username)# Make the GET requestresponse <-GET(url)# Parse the JSON contentdata <-content(response, as ="text", encoding ="UTF-8")json_data <-fromJSON(data, flatten =TRUE)# Convert json data to data frameobservations <-as.data.frame(json_data$results)# Extract latitude and longitude from 'location' columnobservations <- observations %>%mutate(lat =as.numeric(sapply(strsplit(location, ","), `[`, 1)),lng =as.numeric(sapply(strsplit(location, ","), `[`, 2))) %>%select(species_guess, observed_on, location, lat, lng, taxon.iconic_taxon_name, taxon.default_photo.square_url, taxon.name, taxon.preferred_common_name) %>%mutate(taxon.preferred_common_name =str_to_title(taxon.preferred_common_name))# Define an awesomeIconList with iconsicoLst <-awesomeIconList(Plantae =makeAwesomeIcon(text =fa("seedling"), library ="fa", markerColor ="white"),Insecta =makeAwesomeIcon(text =fa("mosquito"), library ="fa", markerColor ="white"),Mammalia =makeAwesomeIcon(text =fa("paw"), library ="fa", markerColor ="white"),Animalia =makeAwesomeIcon(text =fa("shield-cat"), library ="fa", markerColor ="white"),Aves =makeAwesomeIcon(text =fa("crow"), library ="fa", markerColor ="white"),Reptilia =makeAwesomeIcon(text =fa("worm"), library ="fa", markerColor ="white"),Mollusca =makeAwesomeIcon(text =fa("disease"), library ="fa", markerColor ="white"),Fungi =makeAwesomeIcon(text =fa("bacterium"), library ="fa", markerColor ="white"),Unknown =makeAwesomeIcon(text =fa("question-circle"), library ="fa", markerColor ="gray"))# Create Leaflet map with markers and iconsleaflet(observations) %>%addTiles() %>%addAwesomeMarkers(lng =~lng, lat =~lat,icon =~icoLst[taxon.iconic_taxon_name],popup =~paste("Species: ", taxon.preferred_common_name, "<br>","Scientific Name: ", taxon.name, "<br>","Date: ", observed_on, "<br>","Type: ", taxon.iconic_taxon_name, "<br>","Location: ", location,"<br><img src='", taxon.default_photo.square_url, "' alt='Species Image' style='width:50px;height:50px;'>"),clusterOptions =markerClusterOptions() ) %>%addScaleBar(position ="bottomleft") %>%addMiniMap(position ="bottomright", width =100, height =100)
Citation
BibTeX citation:
@online{muir2024,
author = {Muir, Sam},
title = {Mapping My {iNaturalist} Species Sightings Data},
date = {2024-08-08},
url = {https://shmuir.github.io/projects/mapping-species-sightings/},
langid = {en}
}