points2grid {adw} | R Documentation |
Points were to converted grids using a local gridding method.
Description
the irregularly-spaced data of points are converted onto regular latitude-longitude grids by averaging all stations in grid-boxes.
Usage
points2grid(dd, extent, gridsize = 0.5)
Arguments
dd |
a input dataframe which contains the column names of lon, lat, value. |
extent |
a extent numeric vector (latitude and longitude) 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. |
Value
a regular latitude-longitude dataframe grid (grid values).
References
Jones, P. D., and M. Hulme, 1996: Calculating regional climatic time series for temperature and precipitation: Methods and illustrations. Int. J. Climatol., 16, 361–377, https://doi.org/10.1002/(SICI)1097-0088(199604)16:4<361::AID-JOC53>3.0.CO;2-F.
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 <- points2grid(dd, extent = c(110, 117, 31, 37), gridsize = 0.5)
# head(grd)
#
# # example 2
# hmap <- cnmap::getMap(code = "410000", return = "sf") |> sf::st_make_valid()
# grd <- points2grid(dd, extent = hmap, gridsize = 0.5)
# head(grd)
#
# # example 3
# hmap <- cnmap::getMap(code = "410000", return = "sv")
# grd <- points2grid(dd, extent = hmap, gridsize = 0.5)
# head(grd)