{ "collab_server" : "", "contents" : "---\ntitle: \"EMODnet Biology robis demo\"\noutput:\n html_document: default\n html_notebook: default\n---\n\n## Install the robis package\n\nrobis is not available on CRAN. It needs to be installed from GitHub. In the devtools package, you will find the function install_github() which does the installation for you. If devtools is not yet installed on your machine, do that first.\n\n```{r installation, echo=TRUE, message=FALSE, warning=FALSE}\nis_installed <- function(mypkg) is.element(mypkg, installed.packages()[,1])\nif(!is_installed(\"devtools\")) install.packages(\"devtools\")\nif(!is_installed(\"robis\")) devtools::install_github(\"iobis/robis\")\nif(!is_installed(\"leaflet\")) install.packages(\"leaflet\")\nif(!is_installed(\"tidyverse\")) install.packages(\"tidyverse\")\nif(!is_installed(\"rworldxtra\")) install.packages(\"rworldxtra\")\nlibrary(robis)\nlibrary(leaflet)\nlibrary(tidyverse)\nlibrary(rworldxtra)\nlibrary(sf)\n```\n\n## Download occurence data from OBIS\n\n### By scientific name\n\n```{r plotLeafletmap}\n\npol = st_sfc(st_polygon(list(cbind(c(2.3,2.3,8,8,2.3),c(51,56,56,51,51)))))\npol_ext = st_buffer(pol, dist = 1)\n\ndata1 <- occurrence(scientificname = c(\"Cetartiodactyla\"), geometry = st_as_text(pol))\n\ndata2 <- occurrence(scientificname = c(\"Cetartiodactyla\"), geometry = st_as_text(pol_ext))\n \n\nleafletmap(data2)\n\n\n```\n\n\n```{r}\nsort(table(data$phylum))\n\ndata[grep(\"SCANS\", data$datasetName),]\n\n#filter mammals\n#\ndata %>% filter(order == \"Cetartiodactyla\")\ndata %>% filter(institutionCode == \"European Seabirds at Sea\")\n\n\n\n```\n\n\n\n\n```{r}\n\nleaflet(data) %>%\n addTiles(group = \"OSM (default)\") %>%\n addProviderTiles(\"Hydda.Base\", group = \"Hydda.Base\") %>%\n addProviderTiles(\"Esri.WorldImagery\", group = \"Esri.WorldImagery\") %>%\n addWMSTiles(\"http://ows.emodnet-bathymetry.eu/wms\",\n layers = \"emodnet:mean_multicolour\",\n options = WMSTileOptions(version = \"1.3.0\", format=\"image/png\", transparent = T),\n group = \"EMODnet bathymetry\") %>%\n addWMSTiles(\"http://geodata.nationaalgeoregister.nl/natura2000/ows\",\n layers = \"natura2000\",\n options = WMSTileOptions(version = \"1.3.0\", format=\"image/png\", transparent = T, EPSG = \"28992\"), group = \"Natura2000\") %>%\n addProviderTiles(\"OpenSeaMap\", group = \"OpenSeaMap\") %>%\n addCircleMarkers(lat = ~decimalLatitude, lng = ~decimalLongitude, radius = ~log10(individualCount/100), group = \"species\") %>%\n addLayersControl(\n baseGroups = c(\"OSM (default)\", \"Hydda.Base\", \"Esri.WorldImagery\"),\n overlayGroups = c(\"EMODnet bathymetry\", \"OpenSeaMap\", \"observations\", \"Natura2000\")\n ) %>%\n hideGroup(c(\"EMODnet bathymetry\", \"OpenSeaMap\", \"Natura2000\"))\n\n\n```\n\n\nOr plot using ggplot\n\n\n```{r plotGGplot}\n\ndata(\"countriesHigh\")\nworld <- fortify(countriesHigh)\nggplot(data = data, aes(decimalLongitude, decimalLatitude)) +\n geom_polygon(data = world, aes(x = long, y = lat, group = group), fill = \"darkgrey\") +\n geom_point(aes(size = individualCount, color = scientificName)) +\n coord_quickmap(xlim = range(data$decimalLongitude), ylim = range(data$decimalLatitude))\n```\n\n\n\n```{r plot time series}\n\ndata %>% \n ggplot (aes(x = yearcollected, y = individualCount)) + \n geom_boxplot(aes(group = yearcollected)) + \n scale_y_log10()\n\n```\n\n\n\n```{r}\ndata %>% group_by(yearcollected) %>% \n summarize(average = mean(individualCount, na.rm = T)) %>%\n ggplot (aes(x = yearcollected, y = average)) + \n geom_point(aes()) + \n scale_y_log10()\n```\n\n\n\n", "created" : 1510823149805.000, "dirty" : false, "encoding" : "UTF-8", "folds" : "", "hash" : "3700107544", "id" : "F00A1F2F", "lastKnownWriteTime" : 1510826938, "last_content_update" : 1510826938610, "path" : "D:/Tools/R/EMODnetBootcamp/robisDemo.Rmd", "project_path" : "robisDemo.Rmd", "properties" : { }, "relative_order" : 2, "source_on_save" : false, "source_window" : "", "type" : "r_markdown" }