Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable silent reading of CSV-data #182

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Description: This package connects to several Global Fishing Watch APIs to get v
License: Apache License (>= 2)
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Imports:
dplyr,
geojsonsf,
Expand Down
5 changes: 3 additions & 2 deletions R/get_last_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#'
#' @name get_last_report
#' @param key Authorization token. Can be obtained with `gfw_auth()` function
#' @param show_col_types Boolean. Whether to show the column specification when reading the downloaded CSV.
#' @importFrom httr2 request
#' @importFrom httr2 req_headers
#' @importFrom httr2 req_error
Expand Down Expand Up @@ -31,7 +32,7 @@
#' get_last_report(key = gfw_auth())
#' }
#'
get_last_report <- function(key = gfw_auth()) {
get_last_report <- function(key = gfw_auth(), show_col_types = TRUE) {

# Format request
endpoint <- httr2::request("https://gateway.api.globalfishingwatch.org/v3/4wings/last-report") %>%
Expand Down Expand Up @@ -61,7 +62,7 @@ get_last_report <- function(key = gfw_auth()) {

# unzip zip file and extract .csv
file <- unz(temp, names[grepl(".csv$", names)])
return(readr::read_csv(file))
return(readr::read_csv(file, show_col_types = show_col_types))

}

Expand Down
4 changes: 3 additions & 1 deletion R/get_raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' Marine Regions Geographic Identifier or EEZ code).
#' @param region_source source of the region ('EEZ','MPA', 'RFMO' or 'USER_SHAPEFILE')
#' @param key Authorization token. Can be obtained with `gfw_auth()` function
#' @param show_col_types Boolean. Whether to show the column specification when reading the downloaded CSV.
#' @param print_request Boolean. Whether to print the request, for debugging
#' purposes. When contacting the GFW team it will be useful to send this string
#' @importFrom readr read_csv
Expand Down Expand Up @@ -63,6 +64,7 @@ get_raster <- function(spatial_resolution = NULL,
region = NULL,
region_source = NULL,
key = gfw_auth(),
show_col_types = TRUE,
print_request = FALSE) {
date_range <- paste(start_date, end_date, sep = ",")
# Endpoint
Expand Down Expand Up @@ -123,5 +125,5 @@ if (is.null(region_source)) stop("region_source and region params are required")

# unzip zip file and extract .csv
file <- unz(temp, names[grepl(".csv$", names)])
return(readr::read_csv(file))
return(readr::read_csv(file, show_col_types = show_col_types))
}
4 changes: 3 additions & 1 deletion man/get_last_report.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/get_raster.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.