Column1

Tabla Observaciones

Especies Observaciones
Porifera 31
Acanthistius patachonicus 19
Arbacia dufresnii 18
Corynactis carnea 18
Doris fontainii 16
Diaulula punctuolata 14
Cosmasterias lurida 13
Parabunodactis imperfecta 12
Pleurobranchaea maculata 12
Cliona 11
Cycethra verrucosa 10
Allostichaster capensis 9
Ascidiella aspersa 9
Clathria 9
Fissurellidea patagonica 9
Anthothoe chilensis 8
Carcinus maenas 8
Ceriantheopsis 8
Helcogrammoides cunninghami 8
Sebastes oculatus 8
Undaria pinnatifida 8
Anotrichium 7
Halcurias 7
Nemadactylus bergi 7
Aplidium 6
Ascidiacea 6
Ciona robusta 6
Mytilus edulis 6
Odontocymbiola magellanica 6
Pinguipes brasilianus 6
Pseudechinus magellanicus 6
Lissoclinum fragile 5
Phrikoceros mopsus 5
Pseudopercis semifasciata 5
Tripalea clavaria 5
Diplosoma listerianum 4
Leucippa pentagona 4
Myxicola 4
Bivalvia 3
Chrysaora plocamia 3
Cliona chilensis 3
Darwinella 3
Diplodontias singularis 3
Leiosolenus patagonicus 3
Leurocyclus tuberculosus 3
Odontaster 3
Odontaster penicillatus 3
Odontasteridae 3
Paramolgula gregaria 3
Pseudocerotidae 3
Stylatula 3
Anasterias antarctica 2
Bovichtus argentinus 2
Bryozoa 2
Geitodoris patagonica 2
Hymenena 2
Magellania venosa 2
Membranipora 2
Metridium 2
Metridium senile 2
Ophioplocus januarii 2
Ovalipes trimaculatus 2
Pagurus 2
Patagonotothen 2
Phlebobranchia 2
Tegula patagonica 2
Tripylaster philippii 2
Actinopterygii 1
Aequorea 1
Alcyonacea 1
Animalia 1
Ascidia 1
Asterocarpa humilis 1
Aulacomya atra 1
Brachidontinae 1
Bugulina 1
Chaetopteridae 1
Chromista 1
Codium 1
Cyrtograpsus 1
Dallocardia delicatula 1
Darwinellidae 1
Dictyota dichotoma 1
Diplosoma 1
Doryteuthis sanpaulensis 1
Enteroctopus megalocyathus 1
Fissurella radiosa tixierae 1
Gargamella immaculata 1
Holothuroidea 1
Leuckartiara octona 1
Myriogloea major 1
Nacella flammea 1
Neoparacondylactis haraldoi 1
Paralichthys 1
Phycodrys 1
Pinnixa 1
Polycera marplatensis 1
Serolis 1
Sycozoa sigillinoides 1
Trophon geversianus 1
Tubulariidae 1
Tyrinna delicata 1

Column2

Mapa

Phylum

Observaciones por año

Column3

Números

---
title: "Biodiversidad Marina Bahía Pardelas"
output: 
  flexdashboard::flex_dashboard:
    theme: lumen
    social: menu
    source: embed
    logo: https://www.proyectosub.org.ar/wp-content/uploads/2020/04/logoinatproyectosub.png
---

```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
library(ggplot2)
library(plotly)
library(spocc)
library(rinat)
library(mapr)


library(RColorBrewer)
palette(brewer.pal(8, "Set2"))


```

```{r dataread, message=FALSE, warning=FALSE, include=FALSE}


#Extract data from the project "biodiversidad-marina-bahia-pardelas"
#projecy_info <- pardelas_obs <- get_inat_obs_project("biodiversidad-marina-bahia-pardelas", type = "info", raw = FALSE)

#extract observations
#pardelas_obs <- get_inat_obs_project(projecy_info$id, type = "observations")

#create data frame with reduced info
#pardelas_obs_dataframe <- data.frame(name = pardelas_obs$taxon.name,longitude = as.numeric(pardelas_obs$longitude),latitude = as.numeric(pardelas_obs$latitude),user=pardelas_obs$user_login,date= as.Date(pardelas_obs$observed_on), taxonrank=pardelas_obs$taxon.rank,taxonid=pardelas_obs$taxon.id,taxon= pardelas_obs$iconic_taxon.name, stringsAsFactors = FALSE)

#As some of the taxon information  (eg Phylum) is not included in the rinat package we proceed to import data from csv. the package "spocc" shoul be explored for download data.

#Read data downloaded from inat site 
pardelas_obs_web <- read.csv("observations-2022.csv")

#we create a dataframe with the variable of interest.
pardelas_obs_dataframe <- data.frame(
name = pardelas_obs_web$scientific_name,
longitude = pardelas_obs_web$longitude,
latitude = pardelas_obs_web$latitude,
user=pardelas_obs_web$user_login,
date= as.Date(pardelas_obs_web$observed_on),
taxonid=pardelas_obs_web$id,
taxon= pardelas_obs_web$iconic_taxon_name,
kindom= pardelas_obs_web$taxon_kingdom_name,
phylum=pardelas_obs_web$taxon_phylum_name,
class=pardelas_obs_web$taxon_class_name,
order=pardelas_obs_web$taxon_order_name,
genus=pardelas_obs_web$taxon_genus_name,
stringsAsFactors = FALSE)

#add year from date info
pardelas_obs_dataframe$year <- as.numeric(format(pardelas_obs_dataframe$date,"%Y"))

obs_byyear = as.data.frame(table(pardelas_obs_dataframe$year))
colnames(obs_byyear)=c("Año","Observaciones") 

```


Column1{data-width=250}
-------

### Tabla Observaciones {data-width=245}
```{r taxalist}
knitr::kable(as.data.frame(table(reorder(pardelas_obs_dataframe$name,rep(-1,length(pardelas_obs_dataframe$name)),sum))),col.names = c("Especies","Observaciones"))

```


Column2 {.tabset .tabset-fade}
-------

### Mapa
```{r map, message=FALSE, warning=FALSE}

library(XML)
library(OpenStreetMap)
library(lubridate)
library(ggmap)
library(ggplot2)
library(raster)
library(sp)

options(digits=10)
# Reaf the GPX file of each reef track- read one by one and then stored in a dataframe (reef1, reef2..)
pfile <- htmlTreeParse(file = "DII_22-MAR-19_12hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef1 = data.frame(lon = lons,
                         lat = lats)

pfile <- htmlTreeParse(file = "DI_11-MAR-19_14hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef2 = data.frame(lon = lons,
                         lat = lats)

pfile <- htmlTreeParse(file = "MIII_26-MAR-19_13hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef3 = data.frame(lon = lons,
                         lat = lats)

pfile <- htmlTreeParse(file = "MII_11-MAR-19_13hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef4 = data.frame(lon = lons,
                         lat = lats)

pfile <- htmlTreeParse(file = "MI_22-MAR-19_14hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef5 = data.frame(lon = lons,
                         lat = lats)

pfile <- htmlTreeParse(file = "SII_26-MAR-19_14hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef6 = data.frame(lon = lons,
                         lat = lats)

pfile <- htmlTreeParse(file = "SI_11-MAR-19_14hs.gpx", error = function(...) {
}, useInternalNodes = T)
elevations <- as.numeric(xpathSApply(pfile, path = "//trkpt/ele", xmlValue))
times <- xpathSApply(pfile, path = "//trkpt/time", xmlValue)
coords <- xpathSApply(pfile, path = "//trkpt", xmlAttrs)
lats <- as.numeric(coords["lat",])
lons <- as.numeric(coords["lon",])
#save track reef in data frame
track_reef7 = data.frame(lon = lons,
                         lat = lats)


photoicon <- makeIcon(
  iconUrl = "https://www.proyectosub.org.ar/wp-content/uploads/2021/03/cameraicon.png",
  iconWidth = 15, iconHeight = 13,
  iconAnchorX = 15, iconAnchorY = 13)

seapen <- paste("",sep = "
",paste0(""),paste0("Place: ", "Sea Pen"),paste0("Species: ", "Stylatula")) reef <- paste("",sep = "
",paste0(""),paste0("Place: ", "Rocky Reef")) overhang <- paste("",sep = "
",paste0(""),paste0("Place: ", "Rocky Reef Overhang")) sandripplesunderwater <- paste("",sep = "
",paste0(""),paste0("Place: ", "sand ripples underwater")) leaflet() %>% addMiniMap(toggleDisplay = T) %>% addProviderTiles(providers$Esri.WorldImagery) %>% addCircleMarkers(data = pardelas_obs_dataframe, ~longitude, ~latitude,weight = 0.5,col = 'green', fillColor = 'green',radius = 4, fillOpacity = 0.5, stroke = T, label =pardelas_obs_dataframe$name,group = 'Observaciones')%>% addMarkers(-64.256072,-42.625413, popup=seapen, icon = photoicon,group = 'Habitat')%>% addMarkers(-64.265982,-42.623450, popup=reef,icon = photoicon,group = 'Habitat')%>% addMarkers(-64.260400,-42.623689, popup=overhang,icon =photoicon, group = 'Habitat')%>% addMarkers(-64.278155,-42.617193, popup=sandripplesunderwater,icon =photoicon, group = 'Habitat')%>% addPolylines(data = track_reef1, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addPolylines(data = track_reef2, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addPolylines(data = track_reef3, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addPolylines(data = track_reef4, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addPolylines(data = track_reef5, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addPolylines(data = track_reef6, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addPolylines(data = track_reef7, ~lon, ~lat, weight = 3, color = 'red', popup = 'This is a line!', smoothFactor = 3, group = 'Arrecifes')%>% addLayersControl(overlayGroups = c('Habitat', 'Observaciones','Arrecifes'),options = layersControlOptions(collapsed = FALSE),position = 'topright') ``` ### Phylum ```{r donut} ##numbers of observations by phylum taxranks = as.data.frame(table(pardelas_obs_dataframe$phylum)) ##Donut plot p = taxranks %>% plot_ly(labels = ~Var1, values=~Freq) %>% add_pie(hole=0.6) %>% layout(title = ~paste0("Numero total de Taxa: ", length(unique(pardelas_obs_dataframe$taxonid)))) plotly::config(p,displayModeBar = F) ``` ### Observaciones por año ```{r obsbyyear} #plot number of observation by date ggplot(obs_byyear, aes(x=Año,y=Observaciones,group=1)) + geom_line() + geom_point()+ xlab("Año") + ylab("Observaciones") + theme_minimal() ``` Column3{data-width=150} ------- ### Números ```{r} #spp nspp = length(unique(pardelas_obs_dataframe$genus)) gauge(nspp, min=0, max=100,label="Genus") #invertebrates ninvertebrates = length(unique(pardelas_obs_dataframe$name[pardelas_obs_dataframe$phylum=="Porifera"|pardelas_obs_dataframe$phylum=="Mollusca"|pardelas_obs_dataframe$phylum=="Cnidaria"|pardelas_obs_dataframe$phylum==" Echinodermata"|pardelas_obs_dataframe$phylum=="Bryozoa"|pardelas_obs_dataframe$phylum=="Platyhelminthes"|pardelas_obs_dataframe$phylum=="Arthropoda"|pardelas_obs_dataframe$phylum=="Brachiopoda"])) gauge(ninvertebrates, min=0, max=100,label="Invertebrados") #Ascidiacea nAscidiacea = length(unique(pardelas_obs_dataframe$name[pardelas_obs_dataframe$class=="Ascidiacea"])) gauge(nAscidiacea, min=0, max=100,label="Ascidiacea") #fish nfish = length(unique(pardelas_obs_dataframe$name[pardelas_obs_dataframe$taxon=="Actinopterygii"])) gauge(nfish, min=0, max=100,label="Peces") #algae nPlants = length(unique(pardelas_obs_dataframe$name[pardelas_obs_dataframe$kindom=="Plantae"| pardelas_obs_dataframe$taxon=="Chromista"])) gauge(nPlants, min=0, max=100,label="Algas",sectors = gaugeSectors(success = c(0, 40), warning = c(40, 60), danger = c(60, 100), colors = c("green", rgb(0, 1, 0), "#CC664D"))) ```