diff --git a/DESCRIPTION b/DESCRIPTION index c01de9d..05a18ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -8,14 +8,16 @@ Authors@R: c( role = c("aut"), comment = c(ORCID = "0000-0003-0319-4210")), person("Nate", "Miller", , "nate@globalfishingwatch.org", + role = c("aut")), + person("Andrea", "Sánchez-Tapia", , "andrea.sanchez-tapia@globalfishingwatch.org", role = c("aut"), - comment = c(ORCID = "YOUR-ORCID-ID")) + comment = c(ORCID = "0000-0002-3521-4338")) ) Description: This package connects to several Global Fishing Watch APIs to get vessel and events information in an R-friendly format. License: file LICENSE Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 Imports: dplyr, geojsonsf, diff --git a/NAMESPACE b/NAMESPACE index 362a3c4..5cd630f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -23,7 +23,6 @@ importFrom(httr2,request) importFrom(httr2,resp_body_json) importFrom(httr2,resp_body_raw) importFrom(magrittr,"%>%") -importFrom(magrittr,`%>%`) importFrom(purrr,flatten) importFrom(purrr,map) importFrom(purrr,map_chr) diff --git a/R/get_raster.R b/R/get_raster.R index a8d7b8a..fc4ce9b 100644 --- a/R/get_raster.R +++ b/R/get_raster.R @@ -9,7 +9,7 @@ #' EEZ code). See details about geojson formatting. #' @param region_source source of the region ('eez','mpa', 'rfmo' or 'user_json') #' @param key Authorization token. Can be obtained with gfw_auth function -#' @importFrom magrittr `%>%` +#' @importFrom magrittr %>% #' @importFrom readr read_csv #' @importFrom httr2 resp_body_raw #' @importFrom httr2 req_body_raw diff --git a/R/utils.R b/R/utils.R index d2299f2..cbde1a0 100644 --- a/R/utils.R +++ b/R/utils.R @@ -181,7 +181,7 @@ get_region_id <- function(region_name, region_source = 'eez', key) { #' Formats an sf shapefile to a formatted geojson #' #' @param sf_shape The sf shapefile to transform -#' @returns A correctly-formatted geojason to be used in `get_raster()` +#' @returns A correctly-formatted geojson to be used in `get_raster()` #' @importFrom geojsonsf sf_geojson #' @export diff --git a/README.Rmd b/README.Rmd index 7cfcf93..e52c8aa 100644 --- a/README.Rmd +++ b/README.Rmd @@ -7,6 +7,7 @@ output: github_document ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, + eval = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" @@ -21,6 +22,10 @@ knitr::opts_chunk$set( [![Licence](https://img.shields.io/badge/license-Apache%202-blue)](https://opensource.org/licenses/Apache-2.0) +> **Important** +> The current version of `gfwr` gives access to Global Fishing Watch API [version 2](https://globalfishingwatch.org/our-apis/documentation#version-2-api). This version is in Maintenance mode, it will be operational and available but no new functionalities will be added. This version will be Deprecated on April 30 2024. A new version fetching data from [version 3](https://globalfishingwatch.org/our-apis/documentation#version-3-api) is being prepared. + + The `gfwr` R package is a simple wrapper for the Global Fishing Watch (GFW) [APIs](https://globalfishingwatch.org/our-apis/documentation#introduction). It provides convenient functions to freely pull GFW data directly into R in tidy formats. The package currently works with the following APIs: @@ -29,7 +34,7 @@ The package currently works with the following APIs: * [Events API](https://globalfishingwatch.org/our-apis/documentation#events-api): encounters, loitering, port visits and fishing events based on AIS data * [Map Visualization (4Wings API)](https://globalfishingwatch.org/our-apis/documentation#map-visualization-4wings-api): apparent fishing effort based on AIS data -> **Note**: +> **Note**: > See the [Terms of Use](https://globalfishingwatch.org/our-apis/documentation#reference-data) page for GFW APIs for information on our API licenses and rate limits. ## Installation @@ -62,7 +67,7 @@ the [GFW API Portal](https://globalfishingwatch.org/our-apis/tokens). Save this token to your `.Renviron` file (using `usethis::edit_r_environ()`) by adding a variable named `GFW_TOKEN` to the file (`GFW_TOKEN = "PASTE_YOUR_TOKEN_HERE"`). Save the `.Renviron` file and restart the R session to make the edit effective. -Then use the `gfw_auth` helper function to save the information to an object +Then use the `gfw_auth()` helper function to save the information to an object in your R workspace every time you need to extract the token and pass it to subsequent `gfwr` functions. @@ -78,12 +83,12 @@ or this key <- Sys.getenv("GFW_TOKEN") ``` -> **Note**: -> `gfwr` functions are set to use `key = gfw_auth()` by default. +> **Note**: +> `gfwr` functions are set to use `key = gfw_auth()` by default. ## Vessels API -The `get_vessel_info` function allows you to get vessel identity details from the [GFW Vessels API](https://globalfishingwatch.org/our-apis/documentation#introduction-vessels-api). +The `get_vessel_info()` function allows you to get vessel identity details from the [GFW Vessels API](https://globalfishingwatch.org/our-apis/documentation#introduction-vessels-api). There are three search types: `basic`, `advanced`, and `id`. * `basic` search takes features like MMSI, IMO, callsign, shipname as inputs and @@ -92,7 +97,7 @@ identifies all vessels in the specified dataset that match * `id` allows the user to specify the `vessel id` (generated by GFW) > **Note**: -> `vessel id` is an internal ID generated by GFW to connect data accross APIs +> `vessel id` is an internal ID generated by GFW to connect data accross APIs and involves a combination of vessel and tracking data information The user can also specify which identity databases to use: `carrier_vessel`, @@ -100,9 +105,9 @@ The user can also specify which identity databases to use: `carrier_vessel`, ### Examples -To get information of a vessel with MMSI = 224224000 using all datasets: +To get information of a vessel with `MMSI = 224224000` using all datasets: -```{r example_vessel_info_1, eval=T} +```{r example_vessel_info_1} get_vessel_info(query = 224224000, search_type = "basic", dataset = "all", @@ -112,62 +117,63 @@ get_vessel_info(query = 224224000, To combine different fields and do fuzzy matching to search the `carrier vessel` dataset: -```{r example_vessel_info_2, eval=F} +```{r example_vessel_info_2} get_vessel_info(query = "shipname LIKE '%GABU REEFE%' OR imo = '8300949'", search_type = "advanced", dataset = "carrier_vessel", key = key) ``` To specify a `vessel id`: -```{r example_vessel_info_3, eval=F} +```{r example_vessel_info_3} get_vessel_info(query = "8c7304226-6c71-edbe-0b63-c246734b3c01", - search_type = "id", dataset = "carrier_vessel", key = key) + search_type = "id", + dataset = "carrier_vessel", + key = key) ``` To specify more than one `vessel id`: -> **Note**: -
+> **Note**: > No spaces or newlines are permitted between the `vessel ids` -```{r example_vessel_info_4, eval=F} +```{r example_vessel_info_4} get_vessel_info(query = "8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c,71e7da672-2451-17da-b239-857831602eca", - search_type = 'id', key = key) + search_type = "id", key = key) ``` ## Events API -The `get_event` function allows you to get data on specific vessel activities from the [GFW Events API](https://globalfishingwatch.org/our-apis/documentation#events-api). Event types include: +The `get_event()` function allows you to get data on specific vessel activities from the [GFW Events API](https://globalfishingwatch.org/our-apis/documentation#events-api). Event types include: apparent fishing events, potential transshipment events (two-vessel encounters and loitering by refrigerated carrier vessels), and port visits. Find more information in our [caveat documentation](https://globalfishingwatch.org/our-apis/documentation#data-caveat). ### Examples Let's say that you don't know the `vessel id` but you have the MMSI (or other identity information). -You can use `get_vessel_info` function first to extract `vessel id` and then use -it in the `get_event` function: +You can use `get_vessel_info()` function first to extract `vessel id` and then use +it in the `get_event()` function: -```{r example_id_event, eval=T} +```{r example_id_event} vessel_id <- get_vessel_info(query = 224224000, search_type = "basic", key = key)$id ``` To get a list of port visits for that vessel: -```{r example_event_type_1, eval=T} -get_event(event_type='port_visit', +```{r example_event_type_1} +get_event(event_type = "port_visit", vessel = vessel_id, - confidences = '4', + confidences = "4", key = key ) ``` We can also use more than one `vessel id`: -```{r example_event_type_2, eval=F} -get_event(event_type='port_visit', - vessel = '8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c', +```{r example_event_type_2} +get_event(event_type = "port_visit", + vessel = "8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c", confidences = 4, start_date = "2020-01-01", end_date = "2020-02-01", @@ -177,8 +183,8 @@ get_event(event_type='port_visit', Or get encounters for all vessels in a given date range: -```{r example_event_type_3, eval=F} -get_event(event_type='encounter', +```{r example_event_type_3} +get_event(event_type = "encounter", start_date = "2020-01-01", end_date = "2020-01-03", key = key @@ -187,11 +193,13 @@ get_event(event_type='encounter', When a date range is provided to `get_event()` using both `start_date` and `end_date`, any event overlapping that range will be returned, including events that start prior to `start_date` or end after `end_date`. If just `start_date` or `end_date` are provided, results will include all events that end after `start_date` or begin prior to `end_date`, respectively. -> *Note*: Because encounter events are events between two vessels, a single event will be represented twice in the data, once for each vessel. To capture this information and link the related data rows, the `id` field for encounter events includes an additional suffix (1 or 2) separated by a period. The `vessel` field will also contain different information specific to each vessel. +> **Note**: +> Because encounter events are events between two vessels, a single event will be represented twice in the data, once for each vessel. To capture this information and link the related data rows, the `id` field for encounter events includes an additional suffix (1 or 2) separated by a period. The `vessel` field will also contain different information specific to each vessel. + As another example, let's combine the Vessels and Events APIs to get fishing events for a list of 100 USA-flagged trawlers: -```{r example_event_type_4a, eval=T} +```{r example_event_type_4a} # Download the list of USA trawlers usa_trawlers <- get_vessel_info( query = "flag = 'USA' AND geartype = 'trawlers'", @@ -201,13 +209,13 @@ usa_trawlers <- get_vessel_info( ) # Collapse vessel ids into a commas separated list to pass to Events API -usa_trawler_ids <- paste0(usa_trawlers$id[1:100], collapse = ',') +usa_trawler_ids <- paste0(usa_trawlers$id[1:100], collapse = ",") ``` Now get the list of fishing events for these trawlers in January, 2020: -```{r example_event_type_4b, eval=T} -get_event(event_type='fishing', +```{r example_event_type_4b} +get_event(event_type = "fishing", vessel = usa_trawler_ids, start_date = "2020-01-01", end_date = "2020-02-01", @@ -217,8 +225,8 @@ get_event(event_type='fishing', When no events are available, the `get_event()` function returns nothing. -```{r example_event_type_4c, eval=T} -get_event(event_type='fishing', +```{r example_event_type_4c} +get_event(event_type = "fishing", vessel = usa_trawler_ids[2], start_date = "2020-01-01", end_date = "2020-01-01", @@ -228,7 +236,7 @@ get_event(event_type='fishing', ## Map Visualization API -The `get_raster` function gets a raster from the [4Wings API](https://globalfishingwatch.org/our-apis/documentation#map-visualization-4wings-api) and converts the +The `get_raster()` function gets a raster from the [4Wings API](https://globalfishingwatch.org/our-apis/documentation#map-visualization-4wings-api) and converts the response to a data frame. In order to use it, you should specify: * The spatial resolution, which can be `low` (0.1 degree) or `high` (0.01 degree) @@ -243,53 +251,58 @@ response to a data frame. In order to use it, you should specify: Here's an example where we enter the geojson data manually: +> **Note**: +> In `gwfr`, the geojson needs to be enclosed by a `{"geojson": ...}` tag. If you have +> a `geojsonsf::sf_geojson()` object, you can obtain the geojson object with a +simple concatenation: `paste0('{"geojson":', your_geojson,'}')` + -```{r example_map_1, eval=F} +```{r example_map_1} region_json = '{"geojson":{"type":"Polygon","coordinates":[[[-76.11328125,-26.273714024406416],[-76.201171875,-26.980828590472093],[-76.376953125,-27.527758206861883],[-76.81640625,-28.30438068296276],[-77.255859375,-28.767659105691244],[-77.87109375,-29.152161283318918],[-78.486328125,-29.45873118535532],[-79.189453125,-29.61167011519739],[-79.892578125,-29.6880527498568],[-80.595703125,-29.61167011519739],[-81.5625,-29.382175075145277],[-82.177734375,-29.07537517955835],[-82.705078125,-28.6905876542507],[-83.232421875,-28.071980301779845],[-83.49609375,-27.683528083787756],[-83.759765625,-26.980828590472093],[-83.84765625,-26.35249785815401],[-83.759765625,-25.64152637306576],[-83.583984375,-25.16517336866393],[-83.232421875,-24.447149589730827],[-82.705078125,-23.966175871265037],[-82.177734375,-23.483400654325635],[-81.5625,-23.241346102386117],[-80.859375,-22.998851594142906],[-80.15625,-22.917922936146027],[-79.453125,-22.998851594142906],[-78.662109375,-23.1605633090483],[-78.134765625,-23.40276490540795],[-77.431640625,-23.885837699861995],[-76.9921875,-24.28702686537642],[-76.552734375,-24.846565348219727],[-76.2890625,-25.48295117535531],[-76.11328125,-26.273714024406416]]]}}' get_raster( - spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2021-01-01,2021-12-31', + spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-12-31", region = region_json, - region_source = 'user_json', + region_source = "user_json", key = key ) ``` -If you want raster data from a particular EEZ, you can use the `get_region_id` +If you want raster data from a particular EEZ, you can use the `get_region_id()` function to get the EEZ id, enter that code in the `region` argument -of `get_raster` instead of the geojson data (ensuring you specify the `region_source` -as `'eez'`: +of `get_raster()` instead of the geojson data (ensuring you specify the `region_source` +as `"eez"`: -```{r example_map_2, eval=F} +```{r example_map_2} # use EEZ function to get EEZ code of Cote d'Ivoire -code_eez <- get_region_id(region_name = 'CIV', region_source = 'eez', key = key) +code_eez <- get_region_id(region_name = "CIV", region_source = "eez", key = key) -get_raster(spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2021-01-01,2021-10-01', +get_raster(spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-10-01", region = code_eez$id, - region_source = 'eez', + region_source = "eez", key = key) ``` You could search for just one word in the name of the EEZ and then decide which one you want: -```{r example_map_3, eval=T} -(get_region_id(region_name = 'France', region_source = 'eez', key = key)) +```{r example_map_3} +(get_region_id(region_name = "France", region_source = "eez", key = key)) # Let's say we're interested in the French Exclusive Economic Zone, 5677 -get_raster(spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2021-01-01,2021-10-01', +get_raster(spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-10-01", region = 5677, - region_source = 'eez', + region_source = "eez", key = key) ``` @@ -297,16 +310,16 @@ get_raster(spatial_resolution = 'low', A similar approach can be used to search for a specific Marine Protected Area, in this case the Phoenix Island Protected Area (PIPA) -```{r example_map_4, eval=F} +```{r example_map_4} # use region id function to get MPA code of Phoenix Island Protected Area -code_mpa <- get_region_id(region_name = 'Phoenix', region_source = 'mpa', key = key) +code_mpa <- get_region_id(region_name = "Phoenix", region_source = "mpa", key = key) -get_raster(spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2015-01-01,2015-06-01', +get_raster(spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2015-01-01,2015-06-01", region = code_mpa$id[1], - region_source = 'mpa', + region_source = "mpa", key = key) ``` @@ -314,23 +327,23 @@ It is also possible to filter rasters to one of the five regional fisheries mana organizations (RFMO) that manage tuna and tuna-like species. These include `"ICCAT"`, `"IATTC"`,`"IOTC"`, `"CCSBT"` and `"WCPFC"`. -```{r example_map_5, eval=T} -get_raster(spatial_resolution = 'low', - temporal_resolution = 'daily', - group_by = 'flag', - date_range = '2021-01-01,2021-01-15', - region = 'ICCAT', - region_source = 'rfmo', +```{r example_map_5} +get_raster(spatial_resolution = "low", + temporal_resolution = "daily", + group_by = "flag", + date_range = "2021-01-01,2021-01-15", + region = "ICCAT", + region_source = "rfmo", key = key) ``` -The `get_region_id` function also works in reverse. If a region id is passed as +The `get_region_id()` function also works in reverse. If a region id is passed as a `numeric` to the function as the `region_name`, the corresponding region label or iso3 can be returned. This is especially useful when events are returned with regions. -```{r example_region_id, eval=T} +```{r example_region_id} # using same example as above -get_event(event_type = 'fishing', +get_event(event_type = "fishing", vessel = usa_trawler_ids, start_date = "2020-01-01", end_date = "2020-02-01", @@ -338,12 +351,12 @@ get_event(event_type = 'fishing', key = key ) %>% # extract EEZ id code - dplyr::mutate(eez = as.character(purrr::map(purrr::map(regions, pluck, 'eez'), - paste0, collapse = ','))) %>% + dplyr::mutate(eez = as.character(purrr::map(purrr::map(regions, pluck, "eez"), + paste0, collapse = ","))) %>% dplyr::select(id, type, start, end, lat, lon, eez) %>% dplyr::rowwise() %>% dplyr::mutate(eez_name = get_region_id(region_name = as.numeric(eez), - region_source = 'eez', + region_source = "eez", key = key)$label) ``` diff --git a/README.md b/README.md index d656d1f..c8db4e1 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,17 @@ developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.re [![Licence](https://img.shields.io/badge/license-Apache%202-blue)](https://opensource.org/licenses/Apache-2.0) +> **Important** +> The current version of `gfwr` gives access to Global Fishing Watch API +> [version +> 2](https://globalfishingwatch.org/our-apis/documentation#version-2-api). +> This version is in Maintenance mode, it will be operational and +> available but no new functionalities will be added. This version will +> be Deprecated on April 30 2024. A new version fetching data from +> [version +> 3](https://globalfishingwatch.org/our-apis/documentation#version-3-api) +> is being prepared. + The `gfwr` R package is a simple wrapper for the Global Fishing Watch (GFW) [APIs](https://globalfishingwatch.org/our-apis/documentation#introduction). @@ -64,7 +75,7 @@ Save this token to your `.Renviron` file (using the file (`GFW_TOKEN = "PASTE_YOUR_TOKEN_HERE"`). Save the `.Renviron` file and restart the R session to make the edit effective. -Then use the `gfw_auth` helper function to save the information to an +Then use the `gfw_auth()` helper function to save the information to an object in your R workspace every time you need to extract the token and pass it to subsequent `gfwr` functions. @@ -85,8 +96,8 @@ key <- Sys.getenv("GFW_TOKEN") ## Vessels API -The `get_vessel_info` function allows you to get vessel identity details -from the [GFW Vessels +The `get_vessel_info()` function allows you to get vessel identity +details from the [GFW Vessels API](https://globalfishingwatch.org/our-apis/documentation#introduction-vessels-api). There are three search types: `basic`, `advanced`, and `id`. @@ -108,7 +119,8 @@ recommended and is the option set by default. ### Examples -To get information of a vessel with MMSI = 224224000 using all datasets: +To get information of a vessel with `MMSI = 224224000` using all +datasets: ``` r get_vessel_info(query = 224224000, @@ -130,29 +142,56 @@ To combine different fields and do fuzzy matching to search the ``` r get_vessel_info(query = "shipname LIKE '%GABU REEFE%' OR imo = '8300949'", search_type = "advanced", dataset = "carrier_vessel", key = key) +#> # A tibble: 3 × 17 +#> name callsign firstTransmissionDate flag geartype id imo +#> +#> 1 1 ER2732 2019-02-22T21:46:13Z MDA NA 0b7047cb5-58c8-6e63… 8300… +#> 2 2 TJMC996 2022-01-24T09:13:48Z CMR NA 1da8dbc23-3c48-d5ce… 8300… +#> 3 3 D6FJ2 2012-01-02T16:50:42Z COM NA 58cf536b1-1fca-dac3… 8300… +#> # ℹ 10 more variables: lastTransmissionDate , mmsi , msgCount , +#> # posCount , shipname , source , vesselType , +#> # years , dataset , score ``` To specify a `vessel id`: ``` r get_vessel_info(query = "8c7304226-6c71-edbe-0b63-c246734b3c01", - search_type = "id", dataset = "carrier_vessel", key = key) + search_type = "id", + dataset = "carrier_vessel", + key = key) +#> # A tibble: 1 × 16 +#> name callsign firstTransmissionDate flag geartype id imo +#> +#> 1 1 5BWC3 2013-05-15T20:18:31Z CYP NA 8c7304226-6c71-edbe… 9076… +#> # ℹ 9 more variables: lastTransmissionDate , mmsi , msgCount , +#> # posCount , shipname , source , vesselType , +#> # years , dataset ``` To specify more than one `vessel id`: -> **Note**:
No spaces or newlines are permitted between the -> `vessel ids` +> **Note**: +> No spaces or newlines are permitted between the `vessel ids` ``` r get_vessel_info(query = "8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c,71e7da672-2451-17da-b239-857831602eca", - search_type = 'id', key = key) + search_type = "id", key = key) +#> # A tibble: 3 × 16 +#> name callsign firstTransmissionDate flag geartype id imo +#> +#> 1 1 5BWC3 2013-05-15T20:18:31Z CYP 8c7304226-… 9076… +#> 2 2 DTBY3 2013-09-02T03:59:51Z KOR tuna_purse_seines 6583c51e3-… 8919… +#> 3 3 DUQA-7 2017-02-15T05:54:53Z PHL tuna_purse_seines 71e7da672-… 8118… +#> # ℹ 9 more variables: lastTransmissionDate , mmsi , msgCount , +#> # posCount , shipname , source , vesselType , +#> # years , dataset ``` ## Events API -The `get_event` function allows you to get data on specific vessel +The `get_event()` function allows you to get data on specific vessel activities from the [GFW Events API](https://globalfishingwatch.org/our-apis/documentation#events-api). Event types include: apparent fishing events, potential transshipment @@ -163,8 +202,8 @@ documentation](https://globalfishingwatch.org/our-apis/documentation#data-caveat ### Examples Let’s say that you don’t know the `vessel id` but you have the MMSI (or -other identity information). You can use `get_vessel_info` function -first to extract `vessel id` and then use it in the `get_event` +other identity information). You can use `get_vessel_info()` function +first to extract `vessel id` and then use it in the `get_event()` function: ``` r @@ -174,9 +213,9 @@ vessel_id <- get_vessel_info(query = 224224000, search_type = "basic", key = key To get a list of port visits for that vessel: ``` r -get_event(event_type='port_visit', +get_event(event_type = "port_visit", vessel = vessel_id, - confidences = '4', + confidences = "4", key = key ) #> [1] "Downloading 35 events from GFW" @@ -201,23 +240,49 @@ get_event(event_type='port_visit', We can also use more than one `vessel id`: ``` r -get_event(event_type='port_visit', - vessel = '8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c', +get_event(event_type = "port_visit", + vessel = "8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c", confidences = 4, start_date = "2020-01-01", end_date = "2020-02-01", key = key ) +#> [1] "Downloading 3 events from GFW" +#> # A tibble: 3 × 11 +#> id type start end lat lon regions +#> +#> 1 7cd1e3… port… 2019-12-19 23:05:31 2020-01-24 19:05:18 28.1 -15.4 +#> 2 c2f096… port… 2020-01-26 05:52:47 2020-01-29 14:39:33 20.8 -17.0 +#> 3 7c06e4… port… 2020-01-31 02:20:08 2020-02-03 15:56:31 28.1 -15.4 +#> # ℹ 4 more variables: boundingBox , distances , vessel , +#> # event_info ``` Or get encounters for all vessels in a given date range: ``` r -get_event(event_type='encounter', +get_event(event_type = "encounter", start_date = "2020-01-01", end_date = "2020-01-03", key = key ) +#> [1] "Downloading 70 events from GFW" +#> # A tibble: 70 × 11 +#> id type start end lat lon +#> +#> 1 a3cff76a070a919f… enco… 2019-12-31 08:40:00 2020-01-01 07:40:00 57.5 157. +#> 2 a3cff76a070a919f… enco… 2019-12-31 08:40:00 2020-01-01 07:40:00 57.5 157. +#> 3 b059d20534c7fd5f… enco… 2019-12-31 12:00:00 2020-01-01 13:50:00 -17.6 -79.3 +#> 4 b059d20534c7fd5f… enco… 2019-12-31 12:00:00 2020-01-01 13:50:00 -17.6 -79.3 +#> 5 cd07d7e5d65e81b3… enco… 2019-12-31 12:50:00 2020-01-01 09:50:00 -17.7 -79.2 +#> 6 cd07d7e5d65e81b3… enco… 2019-12-31 12:50:00 2020-01-01 09:50:00 -17.7 -79.2 +#> 7 13dac0526c993292… enco… 2019-12-31 14:50:00 2020-01-01 20:20:00 -17.6 -79.4 +#> 8 13dac0526c993292… enco… 2019-12-31 14:50:00 2020-01-01 20:20:00 -17.6 -79.4 +#> 9 2e8b8040d87ad0ae… enco… 2019-12-31 16:00:00 2020-01-01 08:50:00 -3.44 -147. +#> 10 2e8b8040d87ad0ae… enco… 2019-12-31 16:00:00 2020-01-01 08:50:00 -3.44 -147. +#> # ℹ 60 more rows +#> # ℹ 5 more variables: regions , boundingBox , distances , +#> # vessel , event_info ``` When a date range is provided to `get_event()` using both `start_date` @@ -227,12 +292,13 @@ including events that start prior to `start_date` or end after will include all events that end after `start_date` or begin prior to `end_date`, respectively. -> *Note*: Because encounter events are events between two vessels, a -> single event will be represented twice in the data, once for each -> vessel. To capture this information and link the related data rows, -> the `id` field for encounter events includes an additional suffix (1 -> or 2) separated by a period. The `vessel` field will also contain -> different information specific to each vessel. +> **Note**: +> Because encounter events are events between two vessels, a single +> event will be represented twice in the data, once for each vessel. To +> capture this information and link the related data rows, the `id` +> field for encounter events includes an additional suffix (1 or 2) +> separated by a period. The `vessel` field will also contain different +> information specific to each vessel. As another example, let’s combine the Vessels and Events APIs to get fishing events for a list of 100 USA-flagged trawlers: @@ -247,33 +313,33 @@ usa_trawlers <- get_vessel_info( ) # Collapse vessel ids into a commas separated list to pass to Events API -usa_trawler_ids <- paste0(usa_trawlers$id[1:100], collapse = ',') +usa_trawler_ids <- paste0(usa_trawlers$id[1:100], collapse = ",") ``` Now get the list of fishing events for these trawlers in January, 2020: ``` r -get_event(event_type='fishing', +get_event(event_type = "fishing", vessel = usa_trawler_ids, start_date = "2020-01-01", end_date = "2020-02-01", key = key ) -#> [1] "Downloading 102 events from GFW" -#> # A tibble: 102 × 11 +#> [1] "Downloading 106 events from GFW" +#> # A tibble: 106 × 11 #> id type start end lat lon regions #> -#> 1 10b0… fish… 2019-12-31 14:51:06 2020-01-01 02:20:02 29.1 -90.0 -#> 2 e210… fish… 2019-12-31 20:19:35 2020-01-01 03:15:25 28.9 -89.8 -#> 3 5db6… fish… 2020-01-06 08:00:05 2020-01-06 10:20:02 45.9 -124. -#> 4 60c8… fish… 2020-01-07 02:35:53 2020-01-07 20:25:18 41.1 -69.3 -#> 5 ccbe… fish… 2020-01-08 20:44:15 2020-01-09 09:16:14 34.6 -76.6 -#> 6 d20b… fish… 2020-01-09 10:10:14 2020-01-09 13:23:45 34.6 -76.6 -#> 7 cda2… fish… 2020-01-09 17:17:15 2020-01-09 22:47:20 34.6 -76.6 -#> 8 f103… fish… 2020-01-11 03:28:38 2020-01-13 18:25:36 41.1 -69.3 -#> 9 81c8… fish… 2020-01-11 14:10:04 2020-01-11 15:43:09 47.7 -122. -#> 10 0286… fish… 2020-01-11 18:40:04 2020-01-11 20:50:06 47.7 -122. -#> # ℹ 92 more rows +#> 1 0678… fish… 2020-01-01 15:56:25 2020-01-02 00:41:57 35.1 -76.0 +#> 2 4891… fish… 2020-01-02 01:55:51 2020-01-03 00:05:57 35.0 -76.0 +#> 3 d75a… fish… 2020-01-02 23:31:48 2020-01-03 04:37:19 41.1 -71.4 +#> 4 8dda… fish… 2020-01-03 00:39:08 2020-01-03 02:49:08 35.0 -76.0 +#> 5 c85b… fish… 2020-01-03 15:51:15 2020-01-03 18:24:44 39.8 -73.9 +#> 6 1bee… fish… 2020-01-05 00:35:43 2020-01-05 06:11:43 39.7 -73.9 +#> 7 379d… fish… 2020-01-05 04:58:45 2020-01-05 06:31:45 43.7 -124. +#> 8 0b45… fish… 2020-01-06 06:20:19 2020-01-08 02:46:19 39.6 -73.9 +#> 9 04d2… fish… 2020-01-06 21:12:01 2020-01-07 02:35:11 34.6 -76.6 +#> 10 2ad0… fish… 2020-01-07 13:37:54 2020-01-07 15:16:54 34.7 -76.8 +#> # ℹ 96 more rows #> # ℹ 4 more variables: boundingBox , distances , vessel , #> # event_info ``` @@ -282,7 +348,7 @@ When no events are available, the `get_event()` function returns nothing. ``` r -get_event(event_type='fishing', +get_event(event_type = "fishing", vessel = usa_trawler_ids[2], start_date = "2020-01-01", end_date = "2020-01-01", @@ -294,7 +360,7 @@ get_event(event_type='fishing', ## Map Visualization API -The `get_raster` function gets a raster from the [4Wings +The `get_raster()` function gets a raster from the [4Wings API](https://globalfishingwatch.org/our-apis/documentation#map-visualization-4wings-api) and converts the response to a data frame. In order to use it, you should specify: @@ -314,44 +380,88 @@ should specify: Here’s an example where we enter the geojson data manually: +> **Note**: +> In `gwfr`, the geojson needs to be enclosed by a `{"geojson": ...}` +> tag. If you have a `geojsonsf::sf_geojson()` object, you can obtain +> the geojson object with a simple concatenation: +> `paste0('{"geojson":', your_geojson,'}')` + ``` r region_json = '{"geojson":{"type":"Polygon","coordinates":[[[-76.11328125,-26.273714024406416],[-76.201171875,-26.980828590472093],[-76.376953125,-27.527758206861883],[-76.81640625,-28.30438068296276],[-77.255859375,-28.767659105691244],[-77.87109375,-29.152161283318918],[-78.486328125,-29.45873118535532],[-79.189453125,-29.61167011519739],[-79.892578125,-29.6880527498568],[-80.595703125,-29.61167011519739],[-81.5625,-29.382175075145277],[-82.177734375,-29.07537517955835],[-82.705078125,-28.6905876542507],[-83.232421875,-28.071980301779845],[-83.49609375,-27.683528083787756],[-83.759765625,-26.980828590472093],[-83.84765625,-26.35249785815401],[-83.759765625,-25.64152637306576],[-83.583984375,-25.16517336866393],[-83.232421875,-24.447149589730827],[-82.705078125,-23.966175871265037],[-82.177734375,-23.483400654325635],[-81.5625,-23.241346102386117],[-80.859375,-22.998851594142906],[-80.15625,-22.917922936146027],[-79.453125,-22.998851594142906],[-78.662109375,-23.1605633090483],[-78.134765625,-23.40276490540795],[-77.431640625,-23.885837699861995],[-76.9921875,-24.28702686537642],[-76.552734375,-24.846565348219727],[-76.2890625,-25.48295117535531],[-76.11328125,-26.273714024406416]]]}}' get_raster( - spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2021-01-01,2021-12-31', + spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-12-31", region = region_json, - region_source = 'user_json', + region_source = "user_json", key = key ) +#> Rows: 5 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 5 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> +#> 1 -24.2 -77.8 2021 ESP 1 0.42 +#> 2 -24.6 -78.4 2021 ESP 2 0.28 +#> 3 -27.3 -82 2021 ESP 1 0.43 +#> 4 -24.7 -78.5 2021 ESP 1 0.03 +#> 5 -24.7 -78.6 2021 ESP 2 0.96 ``` If you want raster data from a particular EEZ, you can use the -`get_region_id` function to get the EEZ id, enter that code in the -`region` argument of `get_raster` instead of the geojson data (ensuring -you specify the `region_source` as `'eez'`: +`get_region_id()` function to get the EEZ id, enter that code in the +`region` argument of `get_raster()` instead of the geojson data +(ensuring you specify the `region_source` as `"eez"`: ``` r # use EEZ function to get EEZ code of Cote d'Ivoire -code_eez <- get_region_id(region_name = 'CIV', region_source = 'eez', key = key) +code_eez <- get_region_id(region_name = "CIV", region_source = "eez", key = key) -get_raster(spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2021-01-01,2021-10-01', +get_raster(spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-10-01", region = code_eez$id, - region_source = 'eez', + region_source = "eez", key = key) +#> Rows: 573 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 573 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> +#> 1 1.4 -6.6 2021 CPV 1 1.27 +#> 2 2.4 -4 2021 FRA 1 1.04 +#> 3 4.3 -4.1 2021 FRA 2 3.51 +#> 4 5 -5.3 2021 CHN 2 38.4 +#> 5 5.3 -4 2021 SLV 2 17.0 +#> 6 4 -4.3 2021 BLZ 1 4.13 +#> 7 5.1 -4.2 2021 BLZ 1 1.99 +#> 8 2 -6 2021 BLZ 1 4.52 +#> 9 1.2 -6.8 2021 BLZ 1 2.46 +#> 10 1.3 -6.7 2021 BLZ 1 3.46 +#> # ℹ 563 more rows ``` You could search for just one word in the name of the EEZ and then decide which one you want: ``` r -(get_region_id(region_name = 'France', region_source = 'eez', key = key)) +(get_region_id(region_name = "France", region_source = "eez", key = key)) #> # A tibble: 3 × 3 #> id iso3 label #> @@ -360,14 +470,14 @@ decide which one you want: #> 3 48966 FRA Joint regime area Spain / France # Let's say we're interested in the French Exclusive Economic Zone, 5677 -get_raster(spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2021-01-01,2021-10-01', +get_raster(spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-10-01", region = 5677, - region_source = 'eez', + region_source = "eez", key = key) -#> Rows: 5443 Columns: 6 +#> Rows: 5611 Columns: 6 #> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: "," #> chr (1): flag @@ -375,20 +485,20 @@ get_raster(spatial_resolution = 'low', #> #> ℹ Use `spec()` to retrieve the full column specification for this data. #> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. -#> # A tibble: 5,443 × 6 +#> # A tibble: 5,611 × 6 #> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` #> -#> 1 47 -2.9 2021 FRA 61 2692. -#> 2 49.5 -0.2 2021 FRA 59 1029. -#> 3 47.4 -4.2 2021 FRA 40 555. -#> 4 49.2 -4.6 2021 FRA 19 378. -#> 5 45 -1.2 2021 FRA 17 277. -#> 6 49.1 -6 2021 GBR 3 22.2 -#> 7 48.9 -5.9 2021 FRA 20 243. -#> 8 49.1 -5.8 2021 FRA 26 295. -#> 9 49.1 -6.1 2021 FRA 14 66.6 -#> 10 51.2 2 2021 FRA 22 465. -#> # ℹ 5,433 more rows +#> 1 49.1 -5.8 2021 FRA 26 295. +#> 2 49.1 -5.9 2021 FRA 21 180. +#> 3 49 -5.9 2021 FRA 19 244. +#> 4 49 -6.1 2021 FRA 21 239. +#> 5 49.1 -5.6 2021 FRA 18 470. +#> 6 51 1.6 2021 FRA 24 317. +#> 7 50 0 2021 FRA 28 145. +#> 8 49.8 0 2021 FRA 62 1188. +#> 9 42.6 3.2 2021 ESP 9 27.8 +#> 10 42.9 3.3 2021 FRA 18 547. +#> # ℹ 5,601 more rows ``` A similar approach can be used to search for a specific Marine Protected @@ -396,15 +506,37 @@ Area, in this case the Phoenix Island Protected Area (PIPA) ``` r # use region id function to get MPA code of Phoenix Island Protected Area -code_mpa <- get_region_id(region_name = 'Phoenix', region_source = 'mpa', key = key) +code_mpa <- get_region_id(region_name = "Phoenix", region_source = "mpa", key = key) -get_raster(spatial_resolution = 'low', - temporal_resolution = 'yearly', - group_by = 'flag', - date_range = '2015-01-01,2015-06-01', +get_raster(spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2015-01-01,2015-06-01", region = code_mpa$id[1], - region_source = 'mpa', + region_source = "mpa", key = key) +#> Rows: 93 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 93 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> +#> 1 -3.9 -176. 2015 KOR 1 4.88 +#> 2 -4 -176. 2015 KOR 1 1.37 +#> 3 -4.1 -176. 2015 KOR 1 1.57 +#> 4 -2.9 -176. 2015 FSM 1 2.77 +#> 5 -3.3 -176. 2015 1 1.45 +#> 6 -2.8 -176. 2015 KOR 1 9.29 +#> 7 -3.5 -176. 2015 KOR 2 12.3 +#> 8 -3.4 -176. 2015 KOR 1 1.37 +#> 9 -3.5 -176. 2015 KOR 1 10.8 +#> 10 -3.6 -176. 2015 KOR 1 1.08 +#> # ℹ 83 more rows ``` It is also possible to filter rasters to one of the five regional @@ -413,14 +545,14 @@ species. These include `"ICCAT"`, `"IATTC"`,`"IOTC"`, `"CCSBT"` and `"WCPFC"`. ``` r -get_raster(spatial_resolution = 'low', - temporal_resolution = 'daily', - group_by = 'flag', - date_range = '2021-01-01,2021-01-15', - region = 'ICCAT', - region_source = 'rfmo', +get_raster(spatial_resolution = "low", + temporal_resolution = "daily", + group_by = "flag", + date_range = "2021-01-01,2021-01-15", + region = "ICCAT", + region_source = "rfmo", key = key) -#> Rows: 112699 Columns: 6 +#> Rows: 114979 Columns: 6 #> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: "," #> chr (1): flag @@ -429,7 +561,7 @@ get_raster(spatial_resolution = 'low', #> #> ℹ Use `spec()` to retrieve the full column specification for this data. #> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. -#> # A tibble: 112,699 × 6 +#> # A tibble: 114,979 × 6 #> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` #> #> 1 68.7 -51.4 2021-01-08 GRL 1 0.25 @@ -442,17 +574,17 @@ get_raster(spatial_resolution = 'low', #> 8 67 -24 2021-01-04 ISL 3 6.13 #> 9 66.9 -23.9 2021-01-04 ISL 2 1.43 #> 10 66.9 -24.1 2021-01-03 ISL 3 3.4 -#> # ℹ 112,689 more rows +#> # ℹ 114,969 more rows ``` -The `get_region_id` function also works in reverse. If a region id is +The `get_region_id()` function also works in reverse. If a region id is passed as a `numeric` to the function as the `region_name`, the corresponding region label or iso3 can be returned. This is especially useful when events are returned with regions. ``` r # using same example as above -get_event(event_type = 'fishing', +get_event(event_type = "fishing", vessel = usa_trawler_ids, start_date = "2020-01-01", end_date = "2020-02-01", @@ -460,29 +592,29 @@ get_event(event_type = 'fishing', key = key ) %>% # extract EEZ id code - dplyr::mutate(eez = as.character(purrr::map(purrr::map(regions, pluck, 'eez'), - paste0, collapse = ','))) %>% + dplyr::mutate(eez = as.character(purrr::map(purrr::map(regions, pluck, "eez"), + paste0, collapse = ","))) %>% dplyr::select(id, type, start, end, lat, lon, eez) %>% dplyr::rowwise() %>% dplyr::mutate(eez_name = get_region_id(region_name = as.numeric(eez), - region_source = 'eez', + region_source = "eez", key = key)$label) -#> [1] "Downloading 102 events from GFW" -#> # A tibble: 102 × 8 +#> [1] "Downloading 106 events from GFW" +#> # A tibble: 106 × 8 #> # Rowwise: #> id type start end lat lon eez #> -#> 1 10b0ca6f4dc… fish… 2019-12-31 14:51:06 2020-01-01 02:20:02 29.1 -90.0 8456 -#> 2 e2104338c1c… fish… 2019-12-31 20:19:35 2020-01-01 03:15:25 28.9 -89.8 8456 -#> 3 5db68123ed1… fish… 2020-01-06 08:00:05 2020-01-06 10:20:02 45.9 -124. 8456 -#> 4 60c811f3e7e… fish… 2020-01-07 02:35:53 2020-01-07 20:25:18 41.1 -69.3 8456 -#> 5 ccbeb333747… fish… 2020-01-08 20:44:15 2020-01-09 09:16:14 34.6 -76.6 8456 -#> 6 d20bb5e341f… fish… 2020-01-09 10:10:14 2020-01-09 13:23:45 34.6 -76.6 8456 -#> 7 cda29eab7cb… fish… 2020-01-09 17:17:15 2020-01-09 22:47:20 34.6 -76.6 8456 -#> 8 f103e5f79b6… fish… 2020-01-11 03:28:38 2020-01-13 18:25:36 41.1 -69.3 8456 -#> 9 81c8475054e… fish… 2020-01-11 14:10:04 2020-01-11 15:43:09 47.7 -122. 8456 -#> 10 0286436fbd5… fish… 2020-01-11 18:40:04 2020-01-11 20:50:06 47.7 -122. 8456 -#> # ℹ 92 more rows +#> 1 06783a15944… fish… 2020-01-01 15:56:25 2020-01-02 00:41:57 35.1 -76.0 8456 +#> 2 4891aab6703… fish… 2020-01-02 01:55:51 2020-01-03 00:05:57 35.0 -76.0 8456 +#> 3 d75af335992… fish… 2020-01-02 23:31:48 2020-01-03 04:37:19 41.1 -71.4 8456 +#> 4 8ddaf495862… fish… 2020-01-03 00:39:08 2020-01-03 02:49:08 35.0 -76.0 8456 +#> 5 c85b3f8c738… fish… 2020-01-03 15:51:15 2020-01-03 18:24:44 39.8 -73.9 8456 +#> 6 1bee4c2bbe2… fish… 2020-01-05 00:35:43 2020-01-05 06:11:43 39.7 -73.9 8456 +#> 7 379d452b49e… fish… 2020-01-05 04:58:45 2020-01-05 06:31:45 43.7 -124. 8456 +#> 8 0b45ad5daf1… fish… 2020-01-06 06:20:19 2020-01-08 02:46:19 39.6 -73.9 8456 +#> 9 04d20daaf37… fish… 2020-01-06 21:12:01 2020-01-07 02:35:11 34.6 -76.6 8456 +#> 10 2ad00a03bf5… fish… 2020-01-07 13:37:54 2020-01-07 15:16:54 34.7 -76.8 8456 +#> # ℹ 96 more rows #> # ℹ 1 more variable: eez_name ``` diff --git a/docs/404.html b/docs/404.html index dddbee2..2c8cf80 100644 --- a/docs/404.html +++ b/docs/404.html @@ -4,86 +4,99 @@ - + Page not found (404) • gfwr - - - + + + - + + - - Skip to contents + -
-
-
+ + + +
+
+ Content not found. Please use links in the navbar. -
+
+ + +
-
+ diff --git a/docs/CodeOfConduct.html b/docs/CodeOfConduct.html index d1626be..3459bc0 100644 --- a/docs/CodeOfConduct.html +++ b/docs/CodeOfConduct.html @@ -1,47 +1,49 @@ -NA • gfwrNA • gfwr - Skip to contents + -
-
-
+ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e3a4f86..1daf282 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -1,47 +1,49 @@ -License • gfwrLicense • gfwr - Skip to contents + -
-
-
+
+ -
- +
+ diff --git a/docs/LICENSE.html b/docs/LICENSE.html index 4d91757..322460a 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -1,47 +1,49 @@ -NA • gfwrNA • gfwr - Skip to contents + -
-
-
+
+ + + +
+ -
+
+ diff --git a/docs/authors.html b/docs/authors.html index eb33c1e..819d5c2 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,50 +1,52 @@ -Authors and Citation • gfwrAuthors and Citation • gfwr - Skip to contents + -
-
-
+ + +
+
+
+ -
-

Authors

  • Tyler Clavelle. Author, maintainer. @@ -55,43 +57,53 @@

    Authors

  • -

    Nate Miller. Author. +

    Nate Miller. Author. +

    +
  • +
  • +

    Andrea Sánchez-Tapia. Author.

+
+
+

Citation

+ Source: DESCRIPTION +
+
-
-

Citation

-

Source: DESCRIPTION

-

Clavelle T, Joo R, Miller N (2023). +

Clavelle T, Joo R, Miller N, Sánchez-Tapia A (2024). gfwr: Interactions with GFW APIs providing data tibbles. R package version 1.1.1, https://github.com/GlobalFishingWatch/gfwr.

-
@Manual{,
+    
@Manual{,
   title = {gfwr: Interactions with GFW APIs providing data tibbles},
-  author = {Tyler Clavelle and Rocío Joo and Nate Miller},
-  year = {2023},
+  author = {Tyler Clavelle and Rocío Joo and Nate Miller and Andrea Sánchez-Tapia},
+  year = {2024},
   note = {R package version 1.1.1},
   url = {https://github.com/GlobalFishingWatch/gfwr},
 }
-
-
+
+ + -
+
+ diff --git a/docs/bootstrap-toc.css b/docs/bootstrap-toc.css new file mode 100644 index 0000000..5a85941 --- /dev/null +++ b/docs/bootstrap-toc.css @@ -0,0 +1,60 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ + +/* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ + +/* All levels of nav */ +nav[data-toggle='toc'] .nav > li > a { + display: block; + padding: 4px 20px; + font-size: 13px; + font-weight: 500; + color: #767676; +} +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 19px; + color: #563d7c; + text-decoration: none; + background-color: transparent; + border-left: 1px solid #563d7c; +} +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 18px; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-left: 2px solid #563d7c; +} + +/* Nav: second level (shown on .active) */ +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} +nav[data-toggle='toc'] .nav .nav > li > a { + padding-top: 1px; + padding-bottom: 1px; + padding-left: 30px; + font-size: 12px; + font-weight: normal; +} +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 29px; +} +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 28px; + font-weight: 500; +} + +/* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ +nav[data-toggle='toc'] .nav > .active > ul { + display: block; +} diff --git a/docs/bootstrap-toc.js b/docs/bootstrap-toc.js new file mode 100644 index 0000000..1cdd573 --- /dev/null +++ b/docs/bootstrap-toc.js @@ -0,0 +1,159 @@ +/*! + * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) + * Copyright 2015 Aidan Feldman + * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ +(function() { + 'use strict'; + + window.Toc = { + helpers: { + // return all matching elements in the set, or their descendants + findOrFilter: function($el, selector) { + // http://danielnouri.org/notes/2011/03/14/a-jquery-find-that-also-finds-the-root-element/ + // http://stackoverflow.com/a/12731439/358804 + var $descendants = $el.find(selector); + return $el.filter(selector).add($descendants).filter(':not([data-toc-skip])'); + }, + + generateUniqueIdBase: function(el) { + var text = $(el).text(); + var anchor = text.trim().toLowerCase().replace(/[^A-Za-z0-9]+/g, '-'); + return anchor || el.tagName.toLowerCase(); + }, + + generateUniqueId: function(el) { + var anchorBase = this.generateUniqueIdBase(el); + for (var i = 0; ; i++) { + var anchor = anchorBase; + if (i > 0) { + // add suffix + anchor += '-' + i; + } + // check if ID already exists + if (!document.getElementById(anchor)) { + return anchor; + } + } + }, + + generateAnchor: function(el) { + if (el.id) { + return el.id; + } else { + var anchor = this.generateUniqueId(el); + el.id = anchor; + return anchor; + } + }, + + createNavList: function() { + return $(''); + }, + + createChildNavList: function($parent) { + var $childList = this.createNavList(); + $parent.append($childList); + return $childList; + }, + + generateNavEl: function(anchor, text) { + var $a = $(''); + $a.attr('href', '#' + anchor); + $a.text(text); + var $li = $('
  • '); + $li.append($a); + return $li; + }, + + generateNavItem: function(headingEl) { + var anchor = this.generateAnchor(headingEl); + var $heading = $(headingEl); + var text = $heading.data('toc-text') || $heading.text(); + return this.generateNavEl(anchor, text); + }, + + // Find the first heading level (`

    `, then `

    `, etc.) that has more than one element. Defaults to 1 (for `

    `). + getTopLevel: function($scope) { + for (var i = 1; i <= 6; i++) { + var $headings = this.findOrFilter($scope, 'h' + i); + if ($headings.length > 1) { + return i; + } + } + + return 1; + }, + + // returns the elements for the top level, and the next below it + getHeadings: function($scope, topLevel) { + var topSelector = 'h' + topLevel; + + var secondaryLevel = topLevel + 1; + var secondarySelector = 'h' + secondaryLevel; + + return this.findOrFilter($scope, topSelector + ',' + secondarySelector); + }, + + getNavLevel: function(el) { + return parseInt(el.tagName.charAt(1), 10); + }, + + populateNav: function($topContext, topLevel, $headings) { + var $context = $topContext; + var $prevNav; + + var helpers = this; + $headings.each(function(i, el) { + var $newNav = helpers.generateNavItem(el); + var navLevel = helpers.getNavLevel(el); + + // determine the proper $context + if (navLevel === topLevel) { + // use top level + $context = $topContext; + } else if ($prevNav && $context === $topContext) { + // create a new level of the tree and switch to it + $context = helpers.createChildNavList($prevNav); + } // else use the current $context + + $context.append($newNav); + + $prevNav = $newNav; + }); + }, + + parseOps: function(arg) { + var opts; + if (arg.jquery) { + opts = { + $nav: arg + }; + } else { + opts = arg; + } + opts.$scope = opts.$scope || $(document.body); + return opts; + } + }, + + // accepts a jQuery object, or an options object + init: function(opts) { + opts = this.helpers.parseOps(opts); + + // ensure that the data attribute is in place for styling + opts.$nav.attr('data-toggle', 'toc'); + + var $topContext = this.helpers.createChildNavList(opts.$nav); + var topLevel = this.helpers.getTopLevel(opts.$scope); + var $headings = this.helpers.getHeadings(opts.$scope, topLevel); + this.helpers.populateNav($topContext, topLevel, $headings); + } + }; + + $(function() { + $('nav[data-toggle="toc"]').each(function(i, el) { + var $nav = $(el); + Toc.init($nav); + }); + }); +})(); diff --git a/docs/docsearch.css b/docs/docsearch.css new file mode 100644 index 0000000..e5f1fe1 --- /dev/null +++ b/docs/docsearch.css @@ -0,0 +1,148 @@ +/* Docsearch -------------------------------------------------------------- */ +/* + Source: https://github.com/algolia/docsearch/ + License: MIT +*/ + +.algolia-autocomplete { + display: block; + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1 +} + +.algolia-autocomplete .ds-dropdown-menu { + width: 100%; + min-width: none; + max-width: none; + padding: .75rem 0; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, .1); + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .175); +} + +@media (min-width:768px) { + .algolia-autocomplete .ds-dropdown-menu { + width: 175% + } +} + +.algolia-autocomplete .ds-dropdown-menu::before { + display: none +} + +.algolia-autocomplete .ds-dropdown-menu [class^=ds-dataset-] { + padding: 0; + background-color: rgb(255,255,255); + border: 0; + max-height: 80vh; +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestions { + margin-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + padding: 0; + overflow: visible +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + padding: .125rem 1rem; + margin-top: 0; + font-size: 1.3em; + font-weight: 500; + color: #00008B; + border-bottom: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + float: none; + padding-top: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: none; + width: auto; + padding: 0; + text-align: left +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + float: none; + width: auto; + padding: 0 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content::before { + display: none +} + +.algolia-autocomplete .ds-suggestion:not(:first-child) .algolia-docsearch-suggestion--category-header { + padding-top: .75rem; + margin-top: .75rem; + border-top: 1px solid rgba(0, 0, 0, .1) +} + +.algolia-autocomplete .ds-suggestion .algolia-docsearch-suggestion--subcategory-column { + display: block; + padding: .1rem 1rem; + margin-bottom: 0.1; + font-size: 1.0em; + font-weight: 400 + /* display: none */ +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + display: block; + padding: .25rem 1rem; + margin-bottom: 0; + font-size: 0.9em; + font-weight: 400 +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + padding: 0 1rem .5rem; + margin-top: -.25rem; + font-size: 0.8em; + font-weight: 400; + line-height: 1.25 +} + +.algolia-autocomplete .algolia-docsearch-footer { + width: 110px; + height: 20px; + z-index: 3; + margin-top: 10.66667px; + float: right; + font-size: 0; + line-height: 0; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background-image: url("data:image/svg+xml;utf8,"); + background-repeat: no-repeat; + background-position: 50%; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 100%; + height: 100%; + display: block; + transform: translate(-8px); +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + color: #FF8C00; + background: rgba(232, 189, 54, 0.1) +} + + +.algolia-autocomplete .algolia-docsearch-suggestion--text .algolia-docsearch-suggestion--highlight { + box-shadow: inset 0 -2px 0 0 rgba(105, 105, 105, .5) +} + +.algolia-autocomplete .ds-suggestion.ds-cursor .algolia-docsearch-suggestion--content { + background-color: rgba(192, 192, 192, .15) +} diff --git a/docs/docsearch.js b/docs/docsearch.js new file mode 100644 index 0000000..b35504c --- /dev/null +++ b/docs/docsearch.js @@ -0,0 +1,85 @@ +$(function() { + + // register a handler to move the focus to the search bar + // upon pressing shift + "/" (i.e. "?") + $(document).on('keydown', function(e) { + if (e.shiftKey && e.keyCode == 191) { + e.preventDefault(); + $("#search-input").focus(); + } + }); + + $(document).ready(function() { + // do keyword highlighting + /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ + var mark = function() { + + var referrer = document.URL ; + var paramKey = "q" ; + + if (referrer.indexOf("?") !== -1) { + var qs = referrer.substr(referrer.indexOf('?') + 1); + var qs_noanchor = qs.split('#')[0]; + var qsa = qs_noanchor.split('&'); + var keyword = ""; + + for (var i = 0; i < qsa.length; i++) { + var currentParam = qsa[i].split('='); + + if (currentParam.length !== 2) { + continue; + } + + if (currentParam[0] == paramKey) { + keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); + } + } + + if (keyword !== "") { + $(".contents").unmark({ + done: function() { + $(".contents").mark(keyword); + } + }); + } + } + }; + + mark(); + }); +}); + +/* Search term highlighting ------------------------------*/ + +function matchedWords(hit) { + var words = []; + + var hierarchy = hit._highlightResult.hierarchy; + // loop to fetch from lvl0, lvl1, etc. + for (var idx in hierarchy) { + words = words.concat(hierarchy[idx].matchedWords); + } + + var content = hit._highlightResult.content; + if (content) { + words = words.concat(content.matchedWords); + } + + // return unique words + var words_uniq = [...new Set(words)]; + return words_uniq; +} + +function updateHitURL(hit) { + + var words = matchedWords(hit); + var url = ""; + + if (hit.anchor) { + url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; + } else { + url = hit.url + '?q=' + escape(words.join(" ")); + } + + return url; +} diff --git a/docs/index.html b/docs/index.html index 61bc075..17f40d3 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,68 +4,77 @@ - - -An R package for accessing data from Global Fishing Watch APIs • gfwr - - - + +Interactions with GFW APIs providing data tibbles • gfwr + + + - - + + + - - Skip to contents + -
    -
    -
    + +
    + + + + +
    +
    +
    +
    +

    Important
    +The current version of gfwr gives access to Global Fishing Watch API version 2. This version is in Maintenance mode, it will be operational and available but no new functionalities will be added. This version will be Deprecated on April 30 2024. A new version fetching data from version 3 is being prepared.

    +

    The gfwr R package is a simple wrapper for the Global Fishing Watch (GFW) APIs. It provides convenient functions to freely pull GFW data directly into R in tidy formats.

    The package currently works with the following APIs:

    +# Check/install remotes +if (!require("remotes")) + install.packages("remotes") + +remotes::install_github("GlobalFishingWatch/gfwr")

    Once everything is installed, you can load and use gfwr in your scripts with library(gfwr)

    @@ -94,7 +107,7 @@

    InstallationAuthorization

    The use of gfwr requires a GFW API token, which users can request from the GFW API Portal. Save this token to your .Renviron file (using usethis::edit_r_environ()) by adding a variable named GFW_TOKEN to the file (GFW_TOKEN = "PASTE_YOUR_TOKEN_HERE"). Save the .Renviron file and restart the R session to make the edit effective.

    -

    Then use the gfw_auth helper function to save the information to an object in your R workspace every time you need to extract the token and pass it to subsequent gfwr functions.

    +

    Then use the gfw_auth() helper function to save the information to an object in your R workspace every time you need to extract the token and pass it to subsequent gfwr functions.

    So you can do:

     key <- gfw_auth()
    @@ -108,7 +121,7 @@

    Authorization

    Vessels API

    -

    The get_vessel_info function allows you to get vessel identity details from the GFW Vessels API. There are three search types: basic, advanced, and id.

    +

    The get_vessel_info() function allows you to get vessel identity details from the GFW Vessels API. There are three search types: basic, advanced, and id.

    • basic search takes features like MMSI, IMO, callsign, shipname as inputs and identifies all vessels in the specified dataset that match
    • @@ -124,53 +137,80 @@

      Vessels API

      Examples

      -

      To get information of a vessel with MMSI = 224224000 using all datasets:

      +

      To get information of a vessel with MMSI = 224224000 using all datasets:

       get_vessel_info(query = 224224000, 
                       search_type = "basic", 
                       dataset = "all", 
                       key = key)
       #> # A tibble: 1 × 17
      -#>    name callsign first…¹ flag  geart…² id    imo   lastT…³ mmsi  msgCo…⁴ posCo…⁵
      -#>   <int> <chr>    <chr>   <chr> <lgl>   <chr> <chr> <chr>   <chr>   <int>   <int>
      -#> 1     1 EBSJ     2015-1… ESP   NA      3c99… 8733… 2019-1… 2242… 1887249   73677
      -#> # … with 6 more variables: shipname <chr>, source <chr>, vesselType <chr>,
      -#> #   years <list>, dataset <chr>, score <dbl>, and abbreviated variable names
      -#> #   ¹​firstTransmissionDate, ²​geartype, ³​lastTransmissionDate, ⁴​msgCount,
      -#> #   ⁵​posCount
      +#> name callsign firstTransmissionDate flag geartype id imo +#> <int> <chr> <chr> <chr> <lgl> <chr> <chr> +#> 1 1 EBSJ 2015-10-13T15:47:16Z ESP NA 3c99c326d-dd2e-175d… 8733… +#> # ℹ 10 more variables: lastTransmissionDate <chr>, mmsi <chr>, msgCount <int>, +#> # posCount <int>, shipname <chr>, source <chr>, vesselType <chr>, +#> # years <list>, dataset <chr>, score <dbl>

    To combine different fields and do fuzzy matching to search the carrier vessel dataset:

     get_vessel_info(query = "shipname LIKE '%GABU REEFE%' OR imo = '8300949'", 
    -                search_type = "advanced", dataset = "carrier_vessel", key = key)
    + search_type = "advanced", dataset = "carrier_vessel", key = key) +#> # A tibble: 3 × 17 +#> name callsign firstTransmissionDate flag geartype id imo +#> <int> <chr> <chr> <chr> <lgl> <chr> <chr> +#> 1 1 ER2732 2019-02-22T21:46:13Z MDA NA 0b7047cb5-58c8-6e63… 8300… +#> 2 2 TJMC996 2022-01-24T09:13:48Z CMR NA 1da8dbc23-3c48-d5ce… 8300… +#> 3 3 D6FJ2 2012-01-02T16:50:42Z COM NA 58cf536b1-1fca-dac3… 8300… +#> # ℹ 10 more variables: lastTransmissionDate <chr>, mmsi <chr>, msgCount <int>, +#> # posCount <int>, shipname <chr>, source <chr>, vesselType <chr>, +#> # years <list>, dataset <chr>, score <dbl>

    To specify a vessel id:

     get_vessel_info(query = "8c7304226-6c71-edbe-0b63-c246734b3c01", 
    -                search_type = "id", dataset = "carrier_vessel", key = key)
    + search_type = "id", + dataset = "carrier_vessel", + key = key) +#> # A tibble: 1 × 16 +#> name callsign firstTransmissionDate flag geartype id imo +#> <int> <chr> <chr> <chr> <lgl> <chr> <chr> +#> 1 1 5BWC3 2013-05-15T20:18:31Z CYP NA 8c7304226-6c71-edbe… 9076… +#> # ℹ 9 more variables: lastTransmissionDate <chr>, mmsi <chr>, msgCount <int>, +#> # posCount <int>, shipname <chr>, source <chr>, vesselType <chr>, +#> # years <list>, dataset <chr>

    To specify more than one vessel id:

    -

    Note:
    No spaces or newlines are permitted between the vessel ids

    +

    Note:
    +No spaces or newlines are permitted between the vessel ids

     get_vessel_info(query = 
                       "8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c,71e7da672-2451-17da-b239-857831602eca", 
    -                search_type = 'id', key = key)
    + search_type = "id", key = key) +#> # A tibble: 3 × 16 +#> name callsign firstTransmissionDate flag geartype id imo +#> <int> <chr> <chr> <chr> <chr> <chr> <chr> +#> 1 1 5BWC3 2013-05-15T20:18:31Z CYP <NA> 8c7304226-… 9076… +#> 2 2 DTBY3 2013-09-02T03:59:51Z KOR tuna_purse_seines 6583c51e3-… 8919… +#> 3 3 DUQA-7 2017-02-15T05:54:53Z PHL tuna_purse_seines 71e7da672-… 8118… +#> # ℹ 9 more variables: lastTransmissionDate <chr>, mmsi <chr>, msgCount <int>, +#> # posCount <int>, shipname <chr>, source <chr>, vesselType <chr>, +#> # years <list>, dataset <chr>

    Events API

    -

    The get_event function allows you to get data on specific vessel activities from the GFW Events API. Event types include: apparent fishing events, potential transshipment events (two-vessel encounters and loitering by refrigerated carrier vessels), and port visits. Find more information in our caveat documentation.

    +

    The get_event() function allows you to get data on specific vessel activities from the GFW Events API. Event types include: apparent fishing events, potential transshipment events (two-vessel encounters and loitering by refrigerated carrier vessels), and port visits. Find more information in our caveat documentation.

    Examples

    -

    Let’s say that you don’t know the vessel id but you have the MMSI (or other identity information). You can use get_vessel_info function first to extract vessel id and then use it in the get_event function:

    +

    Let’s say that you don’t know the vessel id but you have the MMSI (or other identity information). You can use get_vessel_info() function first to extract vessel id and then use it in the get_event() function:

     vessel_id <- get_vessel_info(query = 224224000, search_type = "basic", key = key)$id

    To get a list of port visits for that vessel:

    +#> # ℹ 25 more rows +#> # ℹ 4 more variables: boundingBox <list>, distances <list>, vessel <list>, +#> # event_info <list>

    We can also use more than one vessel id:

    -get_event(event_type='port_visit',
    -          vessel = '8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c',
    +get_event(event_type = "port_visit",
    +          vessel = "8c7304226-6c71-edbe-0b63-c246734b3c01,6583c51e3-3626-5638-866a-f47c3bc7ef7c",
               confidences = 4,
               start_date = "2020-01-01",
               end_date = "2020-02-01",
               key = key
    -          )
    + ) +#> [1] "Downloading 3 events from GFW" +#> # A tibble: 3 × 11 +#> id type start end lat lon regions +#> <chr> <chr> <dttm> <dttm> <dbl> <dbl> <list> +#> 1 7cd1e3… port… 2019-12-19 23:05:31 2020-01-24 19:05:18 28.1 -15.4 <named list> +#> 2 c2f096… port… 2020-01-26 05:52:47 2020-01-29 14:39:33 20.8 -17.0 <named list> +#> 3 7c06e4… port… 2020-01-31 02:20:08 2020-02-03 15:56:31 28.1 -15.4 <named list> +#> # ℹ 4 more variables: boundingBox <list>, distances <list>, vessel <list>, +#> # event_info <list>

    Or get encounters for all vessels in a given date range:

    -get_event(event_type='encounter',
    +get_event(event_type = "encounter",
               start_date = "2020-01-01",
    -          end_date = "2020-02-01",
    +          end_date = "2020-01-03",
               key = key
    -          )
    -

    As another example, let’s combine the Vessels and Events APIs to get fishing events for a list of 10 USA-flagged trawlers:

    + ) +#> [1] "Downloading 70 events from GFW" +#> # A tibble: 70 × 11 +#> id type start end lat lon +#> <chr> <chr> <dttm> <dttm> <dbl> <dbl> +#> 1 a3cff76a070a919f… enco… 2019-12-31 08:40:00 2020-01-01 07:40:00 57.5 157. +#> 2 a3cff76a070a919f… enco… 2019-12-31 08:40:00 2020-01-01 07:40:00 57.5 157. +#> 3 b059d20534c7fd5f… enco… 2019-12-31 12:00:00 2020-01-01 13:50:00 -17.6 -79.3 +#> 4 b059d20534c7fd5f… enco… 2019-12-31 12:00:00 2020-01-01 13:50:00 -17.6 -79.3 +#> 5 cd07d7e5d65e81b3… enco… 2019-12-31 12:50:00 2020-01-01 09:50:00 -17.7 -79.2 +#> 6 cd07d7e5d65e81b3… enco… 2019-12-31 12:50:00 2020-01-01 09:50:00 -17.7 -79.2 +#> 7 13dac0526c993292… enco… 2019-12-31 14:50:00 2020-01-01 20:20:00 -17.6 -79.4 +#> 8 13dac0526c993292… enco… 2019-12-31 14:50:00 2020-01-01 20:20:00 -17.6 -79.4 +#> 9 2e8b8040d87ad0ae… enco… 2019-12-31 16:00:00 2020-01-01 08:50:00 -3.44 -147. +#> 10 2e8b8040d87ad0ae… enco… 2019-12-31 16:00:00 2020-01-01 08:50:00 -3.44 -147. +#> # ℹ 60 more rows +#> # ℹ 5 more variables: regions <list>, boundingBox <list>, distances <list>, +#> # vessel <list>, event_info <list>
    +

    When a date range is provided to get_event() using both start_date and end_date, any event overlapping that range will be returned, including events that start prior to start_date or end after end_date. If just start_date or end_date are provided, results will include all events that end after start_date or begin prior to end_date, respectively.

    +
    +

    Note:
    +Because encounter events are events between two vessels, a single event will be represented twice in the data, once for each vessel. To capture this information and link the related data rows, the id field for encounter events includes an additional suffix (1 or 2) separated by a period. The vessel field will also contain different information specific to each vessel.

    +
    +

    As another example, let’s combine the Vessels and Events APIs to get fishing events for a list of 100 USA-flagged trawlers:

     # Download the list of USA trawlers
     usa_trawlers <- get_vessel_info(
    @@ -216,41 +288,36 @@ 

    Examples) # Collapse vessel ids into a commas separated list to pass to Events API -usa_trawler_ids <- paste0(usa_trawlers$id[1:10], collapse = ',')

    +usa_trawler_ids <- paste0(usa_trawlers$id[1:100], collapse = ",")

    Now get the list of fishing events for these trawlers in January, 2020:

    -get_event(event_type='fishing',
    +get_event(event_type = "fishing",
               vessel = usa_trawler_ids,
               start_date = "2020-01-01",
               end_date = "2020-02-01",
               key = key
               )
    -#> [1] "Downloading 16 events from GFW"
    -#> # A tibble: 16 × 11
    +#> [1] "Downloading 106 events from GFW"
    +#> # A tibble: 106 × 11
     #>    id    type  start               end                   lat    lon regions     
     #>    <chr> <chr> <dttm>              <dttm>              <dbl>  <dbl> <list>      
    -#>  1 f85e… fish… 2020-01-06 12:35:55 2020-01-06 15:05:39  41.1  -66.4 <named list>
    -#>  2 ccbe… fish… 2020-01-08 20:44:15 2020-01-09 09:16:14  34.6  -76.6 <named list>
    -#>  3 d20b… fish… 2020-01-09 10:10:14 2020-01-09 13:23:45  34.6  -76.6 <named list>
    -#>  4 cda2… fish… 2020-01-09 17:17:15 2020-01-09 22:47:20  34.6  -76.6 <named list>
    -#>  5 2f98… fish… 2020-01-14 14:52:08 2020-01-14 15:45:00  54.2 -165.  <named list>
    -#>  6 642a… fish… 2020-01-20 20:27:13 2020-01-20 23:48:13  34.6  -76.6 <named list>
    -#>  7 4fdb… fish… 2020-01-21 12:42:01 2020-01-21 13:18:00  34.7  -76.8 <named list>
    -#>  8 5101… fish… 2020-01-21 16:09:45 2020-01-22 07:50:52  34.6  -76.6 <named list>
    -#>  9 0404… fish… 2020-01-22 09:19:52 2020-01-22 10:14:21  34.6  -76.6 <named list>
    -#> 10 aacb… fish… 2020-01-23 10:55:05 2020-01-23 13:34:49  33.8  -78.0 <named list>
    -#> 11 4b83… fish… 2020-01-30 19:41:58 2020-01-30 23:08:30  35.1  -75.9 <named list>
    -#> 12 3f33… fish… 2020-01-31 01:09:15 2020-01-31 02:56:23  54.2 -165.  <named list>
    -#> 13 d35f… fish… 2020-01-31 03:46:20 2020-01-31 05:37:04  54.2 -165.  <named list>
    -#> 14 113b… fish… 2020-01-31 16:40:38 2020-01-31 18:04:28  54.2 -165.  <named list>
    -#> 15 0ef5… fish… 2020-01-31 19:14:29 2020-01-31 20:28:14  54.2 -165.  <named list>
    -#> 16 5812… fish… 2020-01-31 21:14:15 2020-01-31 21:56:05  54.2 -165.  <named list>
    -#> # … with 4 more variables: boundingBox <list>, distances <list>, vessel <list>,
    +#>  1 0678… fish… 2020-01-01 15:56:25 2020-01-02 00:41:57  35.1  -76.0 <named list>
    +#>  2 4891… fish… 2020-01-02 01:55:51 2020-01-03 00:05:57  35.0  -76.0 <named list>
    +#>  3 d75a… fish… 2020-01-02 23:31:48 2020-01-03 04:37:19  41.1  -71.4 <named list>
    +#>  4 8dda… fish… 2020-01-03 00:39:08 2020-01-03 02:49:08  35.0  -76.0 <named list>
    +#>  5 c85b… fish… 2020-01-03 15:51:15 2020-01-03 18:24:44  39.8  -73.9 <named list>
    +#>  6 1bee… fish… 2020-01-05 00:35:43 2020-01-05 06:11:43  39.7  -73.9 <named list>
    +#>  7 379d… fish… 2020-01-05 04:58:45 2020-01-05 06:31:45  43.7 -124.  <named list>
    +#>  8 0b45… fish… 2020-01-06 06:20:19 2020-01-08 02:46:19  39.6  -73.9 <named list>
    +#>  9 04d2… fish… 2020-01-06 21:12:01 2020-01-07 02:35:11  34.6  -76.6 <named list>
    +#> 10 2ad0… fish… 2020-01-07 13:37:54 2020-01-07 15:16:54  34.7  -76.8 <named list>
    +#> # ℹ 96 more rows
    +#> # ℹ 4 more variables: boundingBox <list>, distances <list>, vessel <list>,
     #> #   event_info <list>

    When no events are available, the get_event() function returns nothing.

    -get_event(event_type='fishing',
    -          vessel = usa_trawler_ids,
    +get_event(event_type = "fishing",
    +          vessel = usa_trawler_ids[2],
               start_date = "2020-01-01",
               end_date = "2020-01-01",
               key = key
    @@ -262,7 +329,7 @@ 

    Examples

    Map Visualization API

    -

    The get_raster function gets a raster from the 4Wings API and converts the response to a data frame. In order to use it, you should specify:

    +

    The get_raster() function gets a raster from the 4Wings API and converts the response to a data frame. In order to use it, you should specify:

    • The spatial resolution, which can be low (0.1 degree) or high (0.01 degree)
    • The temporal resolution, which can be daily, monthly, or yearly.
    • @@ -277,97 +344,183 @@

      Map Visualization APIExamples

      Here’s an example where we enter the geojson data manually:

      +
      +

      Note:
      +In gwfr, the geojson needs to be enclosed by a {"geojson": ...} tag. If you have a geojsonsf::sf_geojson() object, you can obtain the geojson object with a simple concatenation: paste0('{"geojson":', your_geojson,'}')

      +
       
       region_json = '{"geojson":{"type":"Polygon","coordinates":[[[-76.11328125,-26.273714024406416],[-76.201171875,-26.980828590472093],[-76.376953125,-27.527758206861883],[-76.81640625,-28.30438068296276],[-77.255859375,-28.767659105691244],[-77.87109375,-29.152161283318918],[-78.486328125,-29.45873118535532],[-79.189453125,-29.61167011519739],[-79.892578125,-29.6880527498568],[-80.595703125,-29.61167011519739],[-81.5625,-29.382175075145277],[-82.177734375,-29.07537517955835],[-82.705078125,-28.6905876542507],[-83.232421875,-28.071980301779845],[-83.49609375,-27.683528083787756],[-83.759765625,-26.980828590472093],[-83.84765625,-26.35249785815401],[-83.759765625,-25.64152637306576],[-83.583984375,-25.16517336866393],[-83.232421875,-24.447149589730827],[-82.705078125,-23.966175871265037],[-82.177734375,-23.483400654325635],[-81.5625,-23.241346102386117],[-80.859375,-22.998851594142906],[-80.15625,-22.917922936146027],[-79.453125,-22.998851594142906],[-78.662109375,-23.1605633090483],[-78.134765625,-23.40276490540795],[-77.431640625,-23.885837699861995],[-76.9921875,-24.28702686537642],[-76.552734375,-24.846565348219727],[-76.2890625,-25.48295117535531],[-76.11328125,-26.273714024406416]]]}}'
       
      -get_raster(spatial_resolution = 'low',
      -           temporal_resolution = 'yearly',
      -           group_by = 'flag',
      -           date_range = '2021-01-01,2021-12-31',
      -           region = region_json,
      -           region_source = 'user_json',
      -           key = key)
      -

      If you want raster data from a particular EEZ, you can use the get_region_id function to get the EEZ id, enter that code in the region argument of get_raster instead of the geojson data (ensuring you specify the region_source as 'eez':

      +get_raster( + spatial_resolution = "low", + temporal_resolution = "yearly", + group_by = "flag", + date_range = "2021-01-01,2021-12-31", + region = region_json, + region_source = "user_json", + key = key + ) +#> Rows: 5 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 5 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> +#> 1 -24.2 -77.8 2021 ESP 1 0.42 +#> 2 -24.6 -78.4 2021 ESP 2 0.28 +#> 3 -27.3 -82 2021 ESP 1 0.43 +#> 4 -24.7 -78.5 2021 ESP 1 0.03 +#> 5 -24.7 -78.6 2021 ESP 2 0.96

    +

    If you want raster data from a particular EEZ, you can use the get_region_id() function to get the EEZ id, enter that code in the region argument of get_raster() instead of the geojson data (ensuring you specify the region_source as "eez":

    -
    -# use EEZ function to get EEZ code of Cote d'Ivoire
    -code_eez <- get_region_id(region_name = 'CIV', region_source = 'eez', key = key)
    +# use EEZ function to get EEZ code of Cote d'Ivoire
    +code_eez <- get_region_id(region_name = "CIV", region_source = "eez", key = key)
     
    -get_raster(spatial_resolution = 'low',
    -           temporal_resolution = 'yearly',
    -           group_by = 'flag',
    -           date_range = '2021-01-01,2021-10-01',
    +get_raster(spatial_resolution = "low",
    +           temporal_resolution = "yearly",
    +           group_by = "flag",
    +           date_range = "2021-01-01,2021-10-01",
                region = code_eez$id,
    -           region_source = 'eez',
    -           key = key)
    + region_source = "eez", + key = key) +#> Rows: 573 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 573 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> +#> 1 1.4 -6.6 2021 CPV 1 1.27 +#> 2 2.4 -4 2021 FRA 1 1.04 +#> 3 4.3 -4.1 2021 FRA 2 3.51 +#> 4 5 -5.3 2021 CHN 2 38.4 +#> 5 5.3 -4 2021 SLV 2 17.0 +#> 6 4 -4.3 2021 BLZ 1 4.13 +#> 7 5.1 -4.2 2021 BLZ 1 1.99 +#> 8 2 -6 2021 BLZ 1 4.52 +#> 9 1.2 -6.8 2021 BLZ 1 2.46 +#> 10 1.3 -6.7 2021 BLZ 1 3.46 +#> # ℹ 563 more rows

    You could search for just one word in the name of the EEZ and then decide which one you want:

    -
    -(get_region_id(region_name = 'French', region_source = 'eez', key = key))
    +(get_region_id(region_name = "France", region_source = "eez", key = key))
     #> # A tibble: 3 × 3
    -#>      id iso3  label                                    
    -#>   <dbl> <chr> <chr>                                    
    -#> 1  5677 FRA   French Exclusive Economic Zone           
    -#> 2  8462 FRA   French Guiana Exclusive Economic Zone    
    -#> 3  8440 FRA   French Polynesian Exclusive Economic Zone
    +#>      id iso3  label                           
    +#>   <dbl> <chr> <chr>                           
    +#> 1  5677 FRA   France                          
    +#> 2 48976 FRA   Joint regime area Italy / France
    +#> 3 48966 FRA   Joint regime area Spain / France
     
     # Let's say we're interested in the French Exclusive Economic Zone, 5677
    -get_raster(spatial_resolution = 'low',
    -           temporal_resolution = 'yearly',
    -           group_by = 'flag',
    -           date_range = '2021-01-01,2021-10-01',
    +get_raster(spatial_resolution = "low",
    +           temporal_resolution = "yearly",
    +           group_by = "flag",
    +           date_range = "2021-01-01,2021-10-01",
                region = 5677,
    -           region_source = 'eez',
    +           region_source = "eez",
                key = key)
    -#> Rows: 5421 Columns: 5
    +#> Rows: 5611 Columns: 6
     #> ── Column specification ────────────────────────────────────────────────────────
     #> Delimiter: ","
     #> chr (1): flag
    -#> dbl (4): Lat, Lon, Time Range, Apparent Fishing hours
    +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours
     #> 
     #> ℹ Use `spec()` to retrieve the full column specification for this data.
     #> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
    -#> # A tibble: 5,421 × 5
    -#>      Lat   Lon `Time Range` flag  `Apparent Fishing hours`
    -#>    <dbl> <dbl>        <dbl> <chr>                    <dbl>
    -#>  1  50    -0.5         2021 BEL                      111. 
    -#>  2  49.9  -0.4         2021 FRA                      537. 
    -#>  3  47.8  -6.4         2021 FRA                      156. 
    -#>  4  48.7  -5.6         2021 FRA                      301. 
    -#>  5  48.3  -5.4         2021 FRA                      436. 
    -#>  6  47.4  -4.2         2021 FRA                      555. 
    -#>  7  45.9  -1.4         2021 FRA                      704. 
    -#>  8  50    -0.6         2021 NLD                       40.4
    -#>  9  50.2   0           2021 GBR                      433. 
    -#> 10  46.6  -2.8         2021 FRA                      272. 
    -#> # … with 5,411 more rows
    +#> # A tibble: 5,611 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> +#> 1 49.1 -5.8 2021 FRA 26 295. +#> 2 49.1 -5.9 2021 FRA 21 180. +#> 3 49 -5.9 2021 FRA 19 244. +#> 4 49 -6.1 2021 FRA 21 239. +#> 5 49.1 -5.6 2021 FRA 18 470. +#> 6 51 1.6 2021 FRA 24 317. +#> 7 50 0 2021 FRA 28 145. +#> 8 49.8 0 2021 FRA 62 1188. +#> 9 42.6 3.2 2021 ESP 9 27.8 +#> 10 42.9 3.3 2021 FRA 18 547. +#> # ℹ 5,601 more rows

    A similar approach can be used to search for a specific Marine Protected Area, in this case the Phoenix Island Protected Area (PIPA)

    -
    -# use region id function to get MPA code of Phoenix Island Protected Area
    -code_mpa <- get_region_id(region_name = 'Phoenix', region_source = 'mpa', key = key)
    +# use region id function to get MPA code of Phoenix Island Protected Area
    +code_mpa <- get_region_id(region_name = "Phoenix", region_source = "mpa", key = key)
     
    -get_raster(spatial_resolution = 'low',
    -           temporal_resolution = 'yearly',
    -           group_by = 'flag',
    -           date_range = '2015-01-01,2015-06-01',
    +get_raster(spatial_resolution = "low",
    +           temporal_resolution = "yearly",
    +           group_by = "flag",
    +           date_range = "2015-01-01,2015-06-01",
                region = code_mpa$id[1],
    -           region_source = 'mpa',
    -           key = key)
    + region_source = "mpa", + key = key) +#> Rows: 93 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (5): Lat, Lon, Time Range, Vessel IDs, Apparent Fishing Hours +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 93 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> +#> 1 -3.9 -176. 2015 KOR 1 4.88 +#> 2 -4 -176. 2015 KOR 1 1.37 +#> 3 -4.1 -176. 2015 KOR 1 1.57 +#> 4 -2.9 -176. 2015 FSM 1 2.77 +#> 5 -3.3 -176. 2015 <NA> 1 1.45 +#> 6 -2.8 -176. 2015 KOR 1 9.29 +#> 7 -3.5 -176. 2015 KOR 2 12.3 +#> 8 -3.4 -176. 2015 KOR 1 1.37 +#> 9 -3.5 -176. 2015 KOR 1 10.8 +#> 10 -3.6 -176. 2015 KOR 1 1.08 +#> # ℹ 83 more rows

    It is also possible to filter rasters to one of the five regional fisheries management organizations (RFMO) that manage tuna and tuna-like species. These include "ICCAT", "IATTC","IOTC", "CCSBT" and "WCPFC".

    -get_raster(spatial_resolution = 'low',
    -           temporal_resolution = 'daily',
    -           group_by = 'flag',
    -           date_range = '2021-01-01,2021-01-15',
    -           region = 'ICCAT',
    -           region_source = 'trfmo',
    -           key = key)
    -

    The get_region_id function also works in reverse. If a region id is passed as a numeric to the function as the region_name, the corresponding region label or iso3 can be returned. This is especially useful when events are returned with regions.

    +get_raster(spatial_resolution = "low", + temporal_resolution = "daily", + group_by = "flag", + date_range = "2021-01-01,2021-01-15", + region = "ICCAT", + region_source = "rfmo", + key = key) +#> Rows: 114979 Columns: 6 +#> ── Column specification ──────────────────────────────────────────────────────── +#> Delimiter: "," +#> chr (1): flag +#> dbl (4): Lat, Lon, Vessel IDs, Apparent Fishing Hours +#> date (1): Time Range +#> +#> ℹ Use `spec()` to retrieve the full column specification for this data. +#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. +#> # A tibble: 114,979 × 6 +#> Lat Lon `Time Range` flag `Vessel IDs` `Apparent Fishing Hours` +#> <dbl> <dbl> <date> <chr> <dbl> <dbl> +#> 1 68.7 -51.4 2021-01-08 GRL 1 0.25 +#> 2 68.8 -51.2 2021-01-05 GRL 1 4.78 +#> 3 68.8 -51.2 2021-01-04 GRL 2 0.73 +#> 4 66.9 -24.7 2021-01-03 ISL 11 14.7 +#> 5 66.9 -24.6 2021-01-03 ISL 12 34.5 +#> 6 66.9 -24.5 2021-01-03 ISL 13 40.2 +#> 7 66.8 -24.3 2021-01-04 ISL 15 42.2 +#> 8 67 -24 2021-01-04 ISL 3 6.13 +#> 9 66.9 -23.9 2021-01-04 ISL 2 1.43 +#> 10 66.9 -24.1 2021-01-03 ISL 3 3.4 +#> # ℹ 114,969 more rows +

    The get_region_id() function also works in reverse. If a region id is passed as a numeric to the function as the region_name, the corresponding region label or iso3 can be returned. This is especially useful when events are returned with regions.

     # using same example as above
    -get_event(event_type = 'fishing',
    +get_event(event_type = "fishing",
               vessel = usa_trawler_ids,
               start_date = "2020-01-01",
               end_date = "2020-02-01",
    @@ -375,35 +528,30 @@ 

    Examples= key ) %>% # extract EEZ id code - dplyr::mutate(eez = as.character(purrr::map(purrr::map(regions, pluck, 'eez'), - paste0, collapse = ','))) %>% + dplyr::mutate(eez = as.character(purrr::map(purrr::map(regions, pluck, "eez"), + paste0, collapse = ","))) %>% dplyr::select(id, type, start, end, lat, lon, eez) %>% dplyr::rowwise() %>% dplyr::mutate(eez_name = get_region_id(region_name = as.numeric(eez), - region_source = 'eez', + region_source = "eez", key = key)$label) -#> [1] "Downloading 16 events from GFW" -#> # A tibble: 16 × 8 +#> [1] "Downloading 106 events from GFW" +#> # A tibble: 106 × 8 #> # Rowwise: #> id type start end lat lon eez #> <chr> <chr> <dttm> <dttm> <dbl> <dbl> <chr> -#> 1 f85ee7c4580… fish… 2020-01-06 12:35:55 2020-01-06 15:05:39 41.1 -66.4 8456 -#> 2 ccbeb333747… fish… 2020-01-08 20:44:15 2020-01-09 09:16:14 34.6 -76.6 8456 -#> 3 d20bb5e341f… fish… 2020-01-09 10:10:14 2020-01-09 13:23:45 34.6 -76.6 8456 -#> 4 cda29eab7cb… fish… 2020-01-09 17:17:15 2020-01-09 22:47:20 34.6 -76.6 8456 -#> 5 2f9864dddbc… fish… 2020-01-14 14:52:08 2020-01-14 15:45:00 54.2 -165. 8463 -#> 6 642ab87eb37… fish… 2020-01-20 20:27:13 2020-01-20 23:48:13 34.6 -76.6 8456 -#> 7 4fdb707c504… fish… 2020-01-21 12:42:01 2020-01-21 13:18:00 34.7 -76.8 8456 -#> 8 510194551b5… fish… 2020-01-21 16:09:45 2020-01-22 07:50:52 34.6 -76.6 8456 -#> 9 0404166ac0b… fish… 2020-01-22 09:19:52 2020-01-22 10:14:21 34.6 -76.6 8456 -#> 10 aacb2c24ac0… fish… 2020-01-23 10:55:05 2020-01-23 13:34:49 33.8 -78.0 8456 -#> 11 4b83e209e72… fish… 2020-01-30 19:41:58 2020-01-30 23:08:30 35.1 -75.9 8456 -#> 12 3f339c72f5b… fish… 2020-01-31 01:09:15 2020-01-31 02:56:23 54.2 -165. 8463 -#> 13 d35f8d0f773… fish… 2020-01-31 03:46:20 2020-01-31 05:37:04 54.2 -165. 8463 -#> 14 113b42339a5… fish… 2020-01-31 16:40:38 2020-01-31 18:04:28 54.2 -165. 8463 -#> 15 0ef57dde9c9… fish… 2020-01-31 19:14:29 2020-01-31 20:28:14 54.2 -165. 8463 -#> 16 5812e018011… fish… 2020-01-31 21:14:15 2020-01-31 21:56:05 54.2 -165. 8463 -#> # … with 1 more variable: eez_name <chr>

    +#> 1 06783a15944… fish… 2020-01-01 15:56:25 2020-01-02 00:41:57 35.1 -76.0 8456 +#> 2 4891aab6703… fish… 2020-01-02 01:55:51 2020-01-03 00:05:57 35.0 -76.0 8456 +#> 3 d75af335992… fish… 2020-01-02 23:31:48 2020-01-03 04:37:19 41.1 -71.4 8456 +#> 4 8ddaf495862… fish… 2020-01-03 00:39:08 2020-01-03 02:49:08 35.0 -76.0 8456 +#> 5 c85b3f8c738… fish… 2020-01-03 15:51:15 2020-01-03 18:24:44 39.8 -73.9 8456 +#> 6 1bee4c2bbe2… fish… 2020-01-05 00:35:43 2020-01-05 06:11:43 39.7 -73.9 8456 +#> 7 379d452b49e… fish… 2020-01-05 04:58:45 2020-01-05 06:31:45 43.7 -124. 8456 +#> 8 0b45ad5daf1… fish… 2020-01-06 06:20:19 2020-01-08 02:46:19 39.6 -73.9 8456 +#> 9 04d20daaf37… fish… 2020-01-06 21:12:01 2020-01-07 02:35:11 34.6 -76.6 8456 +#> 10 2ad00a03bf5… fish… 2020-01-07 13:37:54 2020-01-07 15:16:54 34.7 -76.8 8456 +#> # ℹ 96 more rows +#> # ℹ 1 more variable: eez_name <chr>
    @@ -412,7 +560,10 @@

    ContributingContribution Guide and reach out!

    - + -
    + diff --git a/docs/news/index.html b/docs/news/index.html index c2da2e6..b1dcdf0 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -1,51 +1,54 @@ -Changelog • gfwrChangelog • gfwr - Skip to contents + -
    -
    -
    +
    + -
    - +
    + diff --git a/docs/pkgdown.css b/docs/pkgdown.css new file mode 100644 index 0000000..80ea5b8 --- /dev/null +++ b/docs/pkgdown.css @@ -0,0 +1,384 @@ +/* Sticky footer */ + +/** + * Basic idea: https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/ + * Details: https://github.com/philipwalton/solved-by-flexbox/blob/master/assets/css/components/site.css + * + * .Site -> body > .container + * .Site-content -> body > .container .row + * .footer -> footer + * + * Key idea seems to be to ensure that .container and __all its parents__ + * have height set to 100% + * + */ + +html, body { + height: 100%; +} + +body { + position: relative; +} + +body > .container { + display: flex; + height: 100%; + flex-direction: column; +} + +body > .container .row { + flex: 1 0 auto; +} + +footer { + margin-top: 45px; + padding: 35px 0 36px; + border-top: 1px solid #e5e5e5; + color: #666; + display: flex; + flex-shrink: 0; +} +footer p { + margin-bottom: 0; +} +footer div { + flex: 1; +} +footer .pkgdown { + text-align: right; +} +footer p { + margin-bottom: 0; +} + +img.icon { + float: right; +} + +/* Ensure in-page images don't run outside their container */ +.contents img { + max-width: 100%; + height: auto; +} + +/* Fix bug in bootstrap (only seen in firefox) */ +summary { + display: list-item; +} + +/* Typographic tweaking ---------------------------------*/ + +.contents .page-header { + margin-top: calc(-60px + 1em); +} + +dd { + margin-left: 3em; +} + +/* Section anchors ---------------------------------*/ + +a.anchor { + display: none; + margin-left: 5px; + width: 20px; + height: 20px; + + background-image: url(./link.svg); + background-repeat: no-repeat; + background-size: 20px 20px; + background-position: center center; +} + +h1:hover .anchor, +h2:hover .anchor, +h3:hover .anchor, +h4:hover .anchor, +h5:hover .anchor, +h6:hover .anchor { + display: inline-block; +} + +/* Fixes for fixed navbar --------------------------*/ + +.contents h1, .contents h2, .contents h3, .contents h4 { + padding-top: 60px; + margin-top: -40px; +} + +/* Navbar submenu --------------------------*/ + +.dropdown-submenu { + position: relative; +} + +.dropdown-submenu>.dropdown-menu { + top: 0; + left: 100%; + margin-top: -6px; + margin-left: -1px; + border-radius: 0 6px 6px 6px; +} + +.dropdown-submenu:hover>.dropdown-menu { + display: block; +} + +.dropdown-submenu>a:after { + display: block; + content: " "; + float: right; + width: 0; + height: 0; + border-color: transparent; + border-style: solid; + border-width: 5px 0 5px 5px; + border-left-color: #cccccc; + margin-top: 5px; + margin-right: -10px; +} + +.dropdown-submenu:hover>a:after { + border-left-color: #ffffff; +} + +.dropdown-submenu.pull-left { + float: none; +} + +.dropdown-submenu.pull-left>.dropdown-menu { + left: -100%; + margin-left: 10px; + border-radius: 6px 0 6px 6px; +} + +/* Sidebar --------------------------*/ + +#pkgdown-sidebar { + margin-top: 30px; + position: -webkit-sticky; + position: sticky; + top: 70px; +} + +#pkgdown-sidebar h2 { + font-size: 1.5em; + margin-top: 1em; +} + +#pkgdown-sidebar h2:first-child { + margin-top: 0; +} + +#pkgdown-sidebar .list-unstyled li { + margin-bottom: 0.5em; +} + +/* bootstrap-toc tweaks ------------------------------------------------------*/ + +/* All levels of nav */ + +nav[data-toggle='toc'] .nav > li > a { + padding: 4px 20px 4px 6px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; +} + +nav[data-toggle='toc'] .nav > li > a:hover, +nav[data-toggle='toc'] .nav > li > a:focus { + padding-left: 5px; + color: inherit; + border-left: 1px solid #878787; +} + +nav[data-toggle='toc'] .nav > .active > a, +nav[data-toggle='toc'] .nav > .active:hover > a, +nav[data-toggle='toc'] .nav > .active:focus > a { + padding-left: 5px; + font-size: 1.5rem; + font-weight: 400; + color: inherit; + border-left: 2px solid #878787; +} + +/* Nav: second level (shown on .active) */ + +nav[data-toggle='toc'] .nav .nav { + display: none; /* Hide by default, but at >768px, show it */ + padding-bottom: 10px; +} + +nav[data-toggle='toc'] .nav .nav > li > a { + padding-left: 16px; + font-size: 1.35rem; +} + +nav[data-toggle='toc'] .nav .nav > li > a:hover, +nav[data-toggle='toc'] .nav .nav > li > a:focus { + padding-left: 15px; +} + +nav[data-toggle='toc'] .nav .nav > .active > a, +nav[data-toggle='toc'] .nav .nav > .active:hover > a, +nav[data-toggle='toc'] .nav .nav > .active:focus > a { + padding-left: 15px; + font-weight: 500; + font-size: 1.35rem; +} + +/* orcid ------------------------------------------------------------------- */ + +.orcid { + font-size: 16px; + color: #A6CE39; + /* margins are required by official ORCID trademark and display guidelines */ + margin-left:4px; + margin-right:4px; + vertical-align: middle; +} + +/* Reference index & topics ----------------------------------------------- */ + +.ref-index th {font-weight: normal;} + +.ref-index td {vertical-align: top; min-width: 100px} +.ref-index .icon {width: 40px;} +.ref-index .alias {width: 40%;} +.ref-index-icons .alias {width: calc(40% - 40px);} +.ref-index .title {width: 60%;} + +.ref-arguments th {text-align: right; padding-right: 10px;} +.ref-arguments th, .ref-arguments td {vertical-align: top; min-width: 100px} +.ref-arguments .name {width: 20%;} +.ref-arguments .desc {width: 80%;} + +/* Nice scrolling for wide elements --------------------------------------- */ + +table { + display: block; + overflow: auto; +} + +/* Syntax highlighting ---------------------------------------------------- */ + +pre, code, pre code { + background-color: #f8f8f8; + color: #333; +} +pre, pre code { + white-space: pre-wrap; + word-break: break-all; + overflow-wrap: break-word; +} + +pre { + border: 1px solid #eee; +} + +pre .img, pre .r-plt { + margin: 5px 0; +} + +pre .img img, pre .r-plt img { + background-color: #fff; +} + +code a, pre a { + color: #375f84; +} + +a.sourceLine:hover { + text-decoration: none; +} + +.fl {color: #1514b5;} +.fu {color: #000000;} /* function */ +.ch,.st {color: #036a07;} /* string */ +.kw {color: #264D66;} /* keyword */ +.co {color: #888888;} /* comment */ + +.error {font-weight: bolder;} +.warning {font-weight: bolder;} + +/* Clipboard --------------------------*/ + +.hasCopyButton { + position: relative; +} + +.btn-copy-ex { + position: absolute; + right: 0; + top: 0; + visibility: hidden; +} + +.hasCopyButton:hover button.btn-copy-ex { + visibility: visible; +} + +/* headroom.js ------------------------ */ + +.headroom { + will-change: transform; + transition: transform 200ms linear; +} +.headroom--pinned { + transform: translateY(0%); +} +.headroom--unpinned { + transform: translateY(-100%); +} + +/* mark.js ----------------------------*/ + +mark { + background-color: rgba(255, 255, 51, 0.5); + border-bottom: 2px solid rgba(255, 153, 51, 0.3); + padding: 1px; +} + +/* vertical spacing after htmlwidgets */ +.html-widget { + margin-bottom: 10px; +} + +/* fontawesome ------------------------ */ + +.fab { + font-family: "Font Awesome 5 Brands" !important; +} + +/* don't display links in code chunks when printing */ +/* source: https://stackoverflow.com/a/10781533 */ +@media print { + code a:link:after, code a:visited:after { + content: ""; + } +} + +/* Section anchors --------------------------------- + Added in pandoc 2.11: https://github.com/jgm/pandoc-templates/commit/9904bf71 +*/ + +div.csl-bib-body { } +div.csl-entry { + clear: both; +} +.hanging-indent div.csl-entry { + margin-left:2em; + text-indent:-2em; +} +div.csl-left-margin { + min-width:2em; + float:left; +} +div.csl-right-inline { + margin-left:2em; + padding-left:1em; +} +div.csl-indent { + margin-left: 2em; +} diff --git a/docs/pkgdown.js b/docs/pkgdown.js index 5fccd9c..6f0eee4 100644 --- a/docs/pkgdown.js +++ b/docs/pkgdown.js @@ -2,30 +2,70 @@ (function($) { $(function() { - $('nav.navbar').headroom(); + $('.navbar-fixed-top').headroom(); - Toc.init({ - $nav: $("#toc"), - $scope: $("main h2, main h3, main h4, main h5, main h6") + $('body').css('padding-top', $('.navbar').height() + 10); + $(window).resize(function(){ + $('body').css('padding-top', $('.navbar').height() + 10); }); - if ($('#toc').length) { - $('body').scrollspy({ - target: '#toc', - offset: $("nav.navbar").outerHeight() + 1 - }); + $('[data-toggle="tooltip"]').tooltip(); + + var cur_path = paths(location.pathname); + var links = $("#navbar ul li a"); + var max_length = -1; + var pos = -1; + for (var i = 0; i < links.length; i++) { + if (links[i].getAttribute("href") === "#") + continue; + // Ignore external links + if (links[i].host !== location.host) + continue; + + var nav_path = paths(links[i].pathname); + + var length = prefix_length(nav_path, cur_path); + if (length > max_length) { + max_length = length; + pos = i; + } } - // Activate popovers - $('[data-bs-toggle="popover"]').popover({ - container: 'body', - html: true, - trigger: 'focus', - placement: "top", - sanitize: false, - }); + // Add class to parent
  • , and enclosing
  • if in dropdown + if (pos >= 0) { + var menu_anchor = $(links[pos]); + menu_anchor.parent().addClass("active"); + menu_anchor.closest("li.dropdown").addClass("active"); + } + }); + + function paths(pathname) { + var pieces = pathname.split("/"); + pieces.shift(); // always starts with / + + var end = pieces[pieces.length - 1]; + if (end === "index.html" || end === "") + pieces.pop(); + return(pieces); + } + + // Returns -1 if not found + function prefix_length(needle, haystack) { + if (needle.length > haystack.length) + return(-1); - $('[data-bs-toggle="tooltip"]').tooltip(); + // Special case for length-0 haystack, since for loop won't run + if (haystack.length === 0) { + return(needle.length === 0 ? 0 : -1); + } + + for (var i = 0; i < haystack.length; i++) { + if (needle[i] != haystack[i]) + return(i); + } + + return(haystack.length); + } /* Clipboard --------------------------*/ @@ -38,7 +78,7 @@ if(ClipboardJS.isSupported()) { $(document).ready(function() { - var copyButton = ""; + var copyButton = ""; $("div.sourceCode").addClass("hasCopyButton"); @@ -49,108 +89,20 @@ $('.btn-copy-ex').tooltip({container: 'body'}); // Initialize clipboard: - var clipboard = new ClipboardJS('[data-clipboard-copy]', { + var clipboardBtnCopies = new ClipboardJS('[data-clipboard-copy]', { text: function(trigger) { return trigger.parentNode.textContent.replace(/\n#>[^\n]*/g, ""); } }); - clipboard.on('success', function(e) { + clipboardBtnCopies.on('success', function(e) { changeTooltipMessage(e.trigger, 'Copied!'); e.clearSelection(); }); - clipboard.on('error', function() { + clipboardBtnCopies.on('error', function() { changeTooltipMessage(e.trigger,'Press Ctrl+C or Command+C to copy'); }); - }); } - - /* Search marking --------------------------*/ - var url = new URL(window.location.href); - var toMark = url.searchParams.get("q"); - var mark = new Mark("main#main"); - if (toMark) { - mark.mark(toMark, { - accuracy: { - value: "complementary", - limiters: [",", ".", ":", "/"], - } - }); - } - - /* Search --------------------------*/ - /* Adapted from https://github.com/rstudio/bookdown/blob/2d692ba4b61f1e466c92e78fd712b0ab08c11d31/inst/resources/bs4_book/bs4_book.js#L25 */ - // Initialise search index on focus - var fuse; - $("#search-input").focus(async function(e) { - if (fuse) { - return; - } - - $(e.target).addClass("loading"); - var response = await fetch($("#search-input").data("search-index")); - var data = await response.json(); - - var options = { - keys: ["what", "text", "code"], - ignoreLocation: true, - threshold: 0.1, - includeMatches: true, - includeScore: true, - }; - fuse = new Fuse(data, options); - - $(e.target).removeClass("loading"); - }); - - // Use algolia autocomplete - var options = { - autoselect: true, - debug: true, - hint: false, - minLength: 2, - }; - var q; -async function searchFuse(query, callback) { - await fuse; - - var items; - if (!fuse) { - items = []; - } else { - q = query; - var results = fuse.search(query, { limit: 20 }); - items = results - .filter((x) => x.score <= 0.75) - .map((x) => x.item); - if (items.length === 0) { - items = [{dir:"Sorry 😿",previous_headings:"",title:"No results found.",what:"No results found.",path:window.location.href}]; - } - } - callback(items); -} - $("#search-input").autocomplete(options, [ - { - name: "content", - source: searchFuse, - templates: { - suggestion: (s) => { - if (s.title == s.what) { - return `${s.dir} >
    ${s.title}
    `; - } else if (s.previous_headings == "") { - return `${s.dir} >
    ${s.title}
    > ${s.what}`; - } else { - return `${s.dir} >
    ${s.title}
    > ${s.previous_headings} > ${s.what}`; - } - }, - }, - }, - ]).on('autocomplete:selected', function(event, s) { - window.location.href = s.path + "?q=" + q + "#" + s.id; - }); - }); })(window.jQuery || window.$) - - diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index e9f5573..e472f13 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,6 +1,6 @@ -pandoc: '2.18' +pandoc: 3.1.1 pkgdown: 2.0.7 pkgdown_sha: ~ articles: {} -last_built: 2023-01-20T19:39Z +last_built: 2024-01-19T00:58Z diff --git a/docs/reference/get_endpoint.html b/docs/reference/get_endpoint.html index 7aeaa96..cb31668 100644 --- a/docs/reference/get_endpoint.html +++ b/docs/reference/get_endpoint.html @@ -1,61 +1,63 @@ -Function to get API dataset name for given event type — get_endpoint • gfwrFunction to get API dataset name for given event type — get_endpoint • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Function to get API dataset name for given event type

    -
    -

    Usage

    +
    get_endpoint(dataset_type, ...)
    -
    -

    Arguments

    +
    +

    Arguments

    dataset_type

    Type of dataset to get API dataset name for. It can be "port_visit", "fishing", "encounter", "loitering", "eez" or "mpa""

    @@ -65,22 +67,26 @@

    Arguments

    +
    + +
    -
    + diff --git a/docs/reference/get_event.html b/docs/reference/get_event.html index 6880b64..bafb21a 100644 --- a/docs/reference/get_event.html +++ b/docs/reference/get_event.html @@ -1,56 +1,58 @@ -Base function to get event from API and convert response to data frame — get_event • gfwrBase function to get event from API and convert response to data frame — get_event • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Base function to get event from API and convert response to data frame

    -
    -

    Usage

    +
    get_event(
       event_type = "port_visit",
       vessel = NULL,
    @@ -63,8 +65,8 @@ 

    Usage )

    -
    -

    Arguments

    +
    +

    Arguments

    event_type

    Type of event to get data of. One of "port_visit", "encounter", "loitering, or "fishing"

    @@ -97,8 +99,8 @@

    Arguments -

    Details

    +
    +

    Details

    There are currently four available event types and these events are provide for three vessel types - fishing, carrier, and support vessels. Fishing events (event_type = 'fishing') are specific to fishing vessels and loitering @@ -113,22 +115,26 @@

    Details

    -

    +
    + +
    -
    + diff --git a/docs/reference/get_identity_endpoint.html b/docs/reference/get_identity_endpoint.html index 65c85de..e7504e0 100644 --- a/docs/reference/get_identity_endpoint.html +++ b/docs/reference/get_identity_endpoint.html @@ -1,61 +1,63 @@ -Function to get API endpoint name for identity search — get_identity_endpoint • gfwrFunction to get API endpoint name for identity search — get_identity_endpoint • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Function to get API endpoint name for identity search

    -
    -

    Usage

    +
    get_identity_endpoint(dataset_type, search_type, ...)
    -
    -

    Arguments

    +
    +

    Arguments

    dataset_type

    Type of identity dataset to get API dataset name for. It can be "support_vessel", "carrier_vessel" or "fishing_vessel"

    @@ -69,22 +71,26 @@

    Arguments

    +
    + +
    -
    + diff --git a/docs/reference/get_raster.html b/docs/reference/get_raster.html index 6950c22..938271a 100644 --- a/docs/reference/get_raster.html +++ b/docs/reference/get_raster.html @@ -1,60 +1,63 @@ -Base function to get raster from API and convert response to data frame — get_raster • gfwrBase function to get raster from API and convert response to data frame — get_raster • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Base function to get raster from API and convert response to data frame

    -
    -

    Usage

    +
    get_raster(
       spatial_resolution = NULL,
       temporal_resolution = NULL,
       group_by = NULL,
    +  filter_by = NULL,
       date_range = NULL,
       region = NULL,
       region_source = NULL,
    @@ -62,8 +65,8 @@ 

    Usage )

    -
    -

    Arguments

    +
    +

    Arguments

    spatial_resolution

    raster spatial resolution. Can be "low" = 0.1 degree or "high" = 0.01 degree

    @@ -76,43 +79,56 @@

    Arguments -

    Details

    -

    See examples at https://github.com/GlobalFishingWatch/gfwr

    +
    +

    Details

    +

    The user-defined geojson has to be surrounded by a geojson tag, +that can be created using a simple paste:

    +

    geojson_tagged <- paste0('{"geojson":', your_geojson,'}').

    +

    If you have an sf shapefile, you can also use function sf_to_geojson() +to obtain the correctly-formatted geojson.

    -

    +
    + +
    -
    +
    + diff --git a/docs/reference/get_region_id.html b/docs/reference/get_region_id.html index fba0420..487823c 100644 --- a/docs/reference/get_region_id.html +++ b/docs/reference/get_region_id.html @@ -1,61 +1,63 @@ -Function to pull numeric EEZ code using EEZ name — get_region_id • gfwrFunction to pull numeric EEZ code using EEZ name — get_region_id • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Function to pull numeric EEZ code using EEZ name

    -
    -

    Usage

    +
    get_region_id(region_name, region_source = "eez", key)
    -
    -

    Arguments

    +
    +

    Arguments

    region_name

    string or numeric, EEZ/MPA name or EEZ/MPA id

    @@ -68,29 +70,33 @@

    Arguments -

    Value

    +
    +

    Value

    dataframe, eez code and EEZ name for matching EEZs

    -

    +
    + +
    -
    +
    + diff --git a/docs/reference/get_vessel_info.html b/docs/reference/get_vessel_info.html index cd3b15a..fd53262 100644 --- a/docs/reference/get_vessel_info.html +++ b/docs/reference/get_vessel_info.html @@ -1,56 +1,58 @@ -Base function to get vessel information from API and convert response to data frame — get_vessel_info • gfwrBase function to get vessel information from API and convert response to data frame — get_vessel_info • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Base function to get vessel information from API and convert response to data frame

    -
    -

    Usage

    +
    get_vessel_info(
       query = NULL,
       search_type = NULL,
    @@ -59,8 +61,8 @@ 

    Usage )

    -
    -

    Arguments

    +
    +

    Arguments

    query

    search terms to identify vessel

    @@ -77,8 +79,8 @@

    Arguments -

    Details

    +
    +

    Details

    There are three search types. basic search takes features like MMSI, IMO, callsign, shipname as inputs and identifies all vessels in the specified dataset that match. advanced search allows for the use of fuzzy matching with @@ -89,22 +91,26 @@

    Details

    -

    +
    + +
    -
    + diff --git a/docs/reference/gfw_api_request.html b/docs/reference/gfw_api_request.html new file mode 100644 index 0000000..b961540 --- /dev/null +++ b/docs/reference/gfw_api_request.html @@ -0,0 +1,83 @@ + +General function for GFW API requests, including handling of pagination. — gfw_api_request • gfwr + + +
    +
    + + + +
    +
    + + +
    +

    General function for GFW API requests, including handling of pagination.

    +
    + +
    +
    gfw_api_request(endpoint, key)
    +
    + + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/reference/gfw_auth.html b/docs/reference/gfw_auth.html index 7909c17..0a3f0a0 100644 --- a/docs/reference/gfw_auth.html +++ b/docs/reference/gfw_auth.html @@ -1,75 +1,82 @@ -Get user API token from .Renviron — gfw_auth • gfwrGet user API token from .Renviron — gfw_auth • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Get user API token from .Renviron

    -
    -

    Usage

    +
    gfw_auth()
    -
    +
    + +
    -
    +
    + diff --git a/docs/reference/gfwr-package.html b/docs/reference/gfwr-package.html index 5c6a2dc..1386a26 100644 --- a/docs/reference/gfwr-package.html +++ b/docs/reference/gfwr-package.html @@ -1,84 +1,92 @@ -gfwr: Interactions with GFW APIs providing data tibbles — gfwr-package • gfwrgfwr: Interactions with GFW APIs providing data tibbles — gfwr-package • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    This package connects to several Global Fishing Watch APIs to get vessel and events information in an R-friendly format.

    -
    -

    See also

    + -
    -

    Author

    +
    +

    Author

    Maintainer: Tyler Clavelle tyler@globalfishingwatch.org (ORCID)

    Authors:

    -
    +
    + +
    -
    +
    + diff --git a/docs/reference/gist_error_body.html b/docs/reference/gist_error_body.html index 132c6c7..36bc651 100644 --- a/docs/reference/gist_error_body.html +++ b/docs/reference/gist_error_body.html @@ -1,87 +1,92 @@ -Helper function to parse error message data and display appropriately to user -Taken from httr2 docs: https://httr2.r-lib.org/articles/wrapping-apis.html#sending-data"><title>Helper function to parse error message data -and display appropriately to user -Taken from httr2 docs: https://httr2.r-lib.org/articles/wrapping-apis.html#sending-data — gist_error_body • gfwr - Skip to contents - - -
    -
    -
    +
    + +
    -
    +
    + diff --git a/docs/reference/index.html b/docs/reference/index.html index a015825..afbae5a 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,110 +1,108 @@ -Function reference • gfwrFunction reference • gfwr - Skip to contents + -
    -
    -
    +
    +
    +
    -
    -

    All functions

    - - -
    - - - +
    +
    + -
    - - get_endpoint() -
    -
    Function to get API dataset name for given event type
    -
    - - get_event() -
    -
    Base function to get event from API and convert response to data frame
    -
    - - get_identity_endpoint() -
    -
    Function to get API endpoint name for identity search
    -
    - - get_raster() -
    -
    Base function to get raster from API and convert response to data frame
    -
    - - get_region_id() -
    -
    Function to pull numeric EEZ code using EEZ name
    -
    - - get_vessel_info() -
    -
    Base function to get vessel information from API and convert response to data frame
    -
    - - gfw_auth() -
    -
    Get user API token from .Renviron
    -
    -
    + + + + + + + + + + + + + + + + + +
    +

    All functions

    +

    +
    +

    get_endpoint()

    +

    Function to get API dataset name for given event type

    +

    get_event()

    +

    Base function to get event from API and convert response to data frame

    +

    get_identity_endpoint()

    +

    Function to get API endpoint name for identity search

    +

    get_raster()

    +

    Base function to get raster from API and convert response to data frame

    +

    get_region_id()

    +

    Function to pull numeric EEZ code using EEZ name

    +

    get_vessel_info()

    +

    Base function to get vessel information from API and convert response to data frame

    +

    gfw_auth()

    +

    Get user API token from .Renviron

    +

    sf_to_geojson()

    +

    Formats an sf shapefile to a formatted geojson

    + + +
    -
    +
    + diff --git a/docs/reference/make_char.html b/docs/reference/make_char.html index e7795f7..7b68ace 100644 --- a/docs/reference/make_char.html +++ b/docs/reference/make_char.html @@ -1,75 +1,82 @@ -Basic function to make length 1 lists into characters — make_char • gfwrBasic function to make length 1 lists into characters — make_char • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Basic function to make length 1 lists into characters

    -
    -

    Usage

    +
    make_char(col)
    -
    +
    + +
    -
    +
    + diff --git a/docs/reference/make_datetime.html b/docs/reference/make_datetime.html index f8f3f16..c56da67 100644 --- a/docs/reference/make_datetime.html +++ b/docs/reference/make_datetime.html @@ -1,75 +1,82 @@ -Helper function to convert datetime responses — make_datetime • gfwrHelper function to convert datetime responses — make_datetime • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    Helper function to convert datetime responses

    -
    -

    Usage

    +
    make_datetime(x)
    -
    +
    + +
    -
    +
    + diff --git a/docs/reference/pipe.html b/docs/reference/pipe.html index b851cf2..9be7b67 100644 --- a/docs/reference/pipe.html +++ b/docs/reference/pipe.html @@ -1,61 +1,63 @@ -Pipe operator — %>% • gfwrPipe operator — %>% • gfwr - Skip to contents + -
    -
    -
    +
    +
    + + + +
    +
    + -
    +

    See magrittr::%>% for details.

    -
    -

    Usage

    +
    lhs %>% rhs
    -
    -

    Arguments

    +
    +

    Arguments

    lhs

    A value or the magrittr placeholder.

    @@ -64,29 +66,33 @@

    Arguments -

    Value

    +
    +

    Value

    The result of calling rhs(lhs).

    -

    +
    + +
    -
    +
    + diff --git a/docs/reference/sf_to_geojson.html b/docs/reference/sf_to_geojson.html new file mode 100644 index 0000000..cd299f6 --- /dev/null +++ b/docs/reference/sf_to_geojson.html @@ -0,0 +1,97 @@ + +Formats an sf shapefile to a formatted geojson — sf_to_geojson • gfwr + + +
    +
    + + + +
    +
    + + +
    +

    Formats an sf shapefile to a formatted geojson

    +
    + +
    +
    sf_to_geojson(sf_shape)
    +
    + +
    +

    Arguments

    +
    sf_shape
    +

    The sf shapefile to transform

    + +
    +
    +

    Value

    + + +

    A correctly-formatted geojson to be used in get_raster()

    + + +
    + +
    + +
    + + +
    + +
    +

    Site built with pkgdown 2.0.7.

    +
    + +
    + + + + + + + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index e76fb33..92b9df5 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -42,6 +42,9 @@ /reference/get_vessel_info.html + + /reference/gfw_api_request.html + /reference/gfw_auth.html @@ -66,4 +69,7 @@ /reference/pipe.html + + /reference/sf_to_geojson.html + diff --git a/man/gfwr-package.Rd b/man/gfwr-package.Rd index 3d4181b..acbeaca 100644 --- a/man/gfwr-package.Rd +++ b/man/gfwr-package.Rd @@ -22,7 +22,8 @@ Useful links: Authors: \itemize{ \item Rocío Joo \email{rocio.joo@globalfishingwatch.org} (\href{https://orcid.org/0000-0003-0319-4210}{ORCID}) - \item Nate Miller \email{nate@globalfishingwatch.org} (\href{https://orcid.org/YOUR-ORCID-ID}{ORCID}) + \item Nate Miller \email{nate@globalfishingwatch.org} + \item Andrea Sánchez-Tapia \email{andrea.sanchez-tapia@globalfishingwatch.org} (\href{https://orcid.org/0000-0002-3521-4338}{ORCID}) } } diff --git a/man/sf_to_geojson.Rd b/man/sf_to_geojson.Rd index 6ab5646..e8ec44f 100644 --- a/man/sf_to_geojson.Rd +++ b/man/sf_to_geojson.Rd @@ -10,7 +10,7 @@ sf_to_geojson(sf_shape) \item{sf_shape}{The sf shapefile to transform} } \value{ -A correctly-formatted geojason to be used in \code{get_raster()} +A correctly-formatted geojson to be used in \code{get_raster()} } \description{ Formats an sf shapefile to a formatted geojson