adw {adw}R Documentation

Angular Distance Weighting Interpolation.

Description

The irregularly-spaced data are interpolated onto regular latitude-longitude grids by weighting each station according to its distance and angle from the center of a search radius.

Usage

adw(ds, extent, gridsize = 5, cdd = 1000, m = 4, nmin = 3, nmax = 10)

Arguments

ds

a input dataframe which contains the column names of lon, lat, value.

extent

a extent numeric vector of length 4 in the order c(xmin, xmax, ymin, ymax), or a polygon object with class 'sf' (package 'sf'), or a polygon object with class 'SpatVector' (package 'terra'). Assume that the coordinate reference system is WGS1984 (EPSG: 4326).

gridsize

the grid size, i.e. the grid resolution. units: degree.

cdd

correlation decay distance, i.e. the maximum search radius. unit: kilometer. default value: 1000km.

m

is used to adjust the weighting function further, higher values of m increase the rate at which the weight decays with distance. default value 4.

nmin

the minimum number of observation points required to interpolate a grid within the search radius (i.e. cdd); if the number of stations within the search ridius (cdd) is less than nmin, a missing value will be generated to fill this grid. default value 3.

nmax

The number of nearest points within the search radius to use for interpolation. default value 10.

Value

a regular latitude-longitude dataframe grid (interpoled values).

References

Caesar, J., L. Alexander, and R. Vose, 2006: Large-scale changes in observed daily maximum and minimum temperatures: Creation and analysis of a new gridded data set. Journal of Geophysical Research, 111, https://doi.org/10.1029/2005JD006280.

Examples

set.seed(2)
dd <- data.frame(lon = runif(100, min = 110, max = 117),
                 lat = runif(100, min = 31, max = 37),
                 value = runif(100, min = -10, max = 10))
head(dd)

# example 1
grd <- adw(dd, extent = c(110, 117, 31, 37), gridsize = 0.5, cdd = 500)
head(grd)

# example 2
urlmap <- "https://geo.datav.aliyun.com/areas_v3/bound/410000.json"
hmap <- sf::read_sf(urlmap, as_tibble = FALSE) |> sf::st_make_valid() # return a 'sf' object.
grd <- adw_sf(dd, extent = hmap, gridsize = 0.5, cdd = 500)
head(grd)

# example 3
urlmap <- "https://geo.datav.aliyun.com/areas_v3/bound/410000.json"
hmap <- terra::vect(urlmap) # return a 'SpatVector' object.
grd <- adw(dd, extent = hmap, gridsize = 0.5, cdd = 500)
head(grd)

[Package adw version 0.3.1 Index]