restrict_to_country {SeaVal} | R Documentation |
restricts data to a specified country
Description
Restricts a dataset to one or more countries, specified by their names. If you have lon/lat data and don't know
which countries these coordinates belong to, see add_country_names
. Can restrict data to a rectangle around a given country
as well (usually looks nicer for plotting).
Usage
restrict_to_country(dt, ct, rectangle = FALSE, tol = 1)
Arguments
dt |
the data table. |
ct |
name of the country, or vector containing multiple country names |
rectangle |
logical. If FALSE (default), the data is restricted to the gridcells for which the centerpoint lies within the selected country (e.g. for computing mean scores for a country). If TRUE, the data is kept for a rectangle containing the entire country, therefore also containing gridpoints outside the country. This is the preferred option for plotting data for a specific country. |
tol |
Only used when |
Value
the data table, restricted to the selected country
Examples
# example data:
ex_dt = chirps_monthly[lat < 0 & month == 11 & year == 2020]
dt = restrict_to_country(ex_dt,'Kenya')