R/get_event.R
get_event_stats.Rd
Base function to get events stats from API and convert response to data frame
Type of event to get data of. A vector with any combination of "ENCOUNTER", "FISHING", "GAP", "LOITERING", "PORT_VISIT"
Filters for types of vessels during the encounter. A vector with any combination of: "CARRIER-FISHING", "FISHING-CARRIER", "FISHING-SUPPORT", "SUPPORT-FISHING"
A vector of vesselIds, obtained via the get_vessel_info()
function
Optional. A vector of vessel types, any combination of: "FISHING", "CARRIER", "SUPPORT", "PASSENGER", "OTHER_NON_FISHING", "SEISMIC_VESSEL", "BUNKER_OR_TANKER", "CARGO"
Start of date range to search events, in YYYY-MM-DD format and including this date
End of date range to search events, in YYYY-MM-DD format and excluding this date
Optional but mandatory if using the argument region. Source of the region. If 'EEZ','MPA', 'RFMO', then the value for the argument region must be the code for that region. If 'USER_SHAPEFILE', then region has to be an sf object
GFW region code (such as an EEZ, MPA or RFMO code) or a formatted geojson shape. See Details about formatting the geojson.
Time series granularity. Must be a string. Possible values: 'HOUR', 'DAY', 'MONTH', 'YEAR'.
duration, in minutes, of the event, ex. 30
Confidence levels (1-4) of events (port visits only)
Authorization token. Can be obtained with gfw_auth() function
Boolean. Whether to print the number of events returned by the request
Boolean. Whether to print the request, for debugging purposes. When contacting the GFW team it will be useful to send this string
Other arguments
There are currently four available event types and these events are provided
for three vessel types - fishing, carrier, and support vessels.
Fishing events (event_type = "FISHING"
) are specific to fishing vessels and
loitering events (event_type = "LOITERING"
) are specific to carrier vessels.
Port visits (event_type = "PORT_VISIT"
) and encounters
(event_type = "ENCOUNTER"
) are available for all vessel types. For more
details about the various event types, see the
GFW API documentation.
The user-defined geojson has to be surrounded by a geojson tag, that can be created using a simple paste:
If you have an sf shapefile, you can also use function sf_to_geojson()
to obtain the correctly-formatted geojson.
if (FALSE) {
library(gfwr)
# stats for encounters involving Russian carriers in given time range
get_event_stats(event_type = 'ENCOUNTER',
encounter_types = c("CARRIER-FISHING","FISHING-CARRIER"),
vessel_types = 'CARRIER',
start_date = "2018-01-01",
end_date = "2023-01-31",
flags = 'RUS',
duration = 60,
interval = "YEAR",
key = gfw_auth())
# port visits stats in a region (Senegal)
get_event_stats(event_type = 'PORT_VISIT',
start_date = "2018-01-01",
end_date = "2019-01-31",
confidences = c('3','4'),
region = 8371,
region_source = 'EEZ',
interval = "YEAR")
}