Returns the centre-point longitude and latitude of each cell.
Arguments
- cell
An a5_cell vector (or character coercible to one).
- as_dataframe
Logical scalar controlling the return container. When
FALSE(default), centroids are returned as awk::xy()vector with WGS 84 CRS, the geographic-typed form that plugs into wk/sf pipelines. WhenTRUE, centroids are returned as a basedata.framewith columnslonandlat.
Value
A wk::xy() vector (if as_dataframe = FALSE) or a
data.frame with columns lon and lat (if as_dataframe = TRUE).
See also
a5_lonlat_to_cell() for the inverse operation,
a5_cell_to_boundary() for full cell polygons.
Examples
cell <- a5_lonlat_to_cell(-3.19, 55.95, resolution = 5)
a5_cell_to_lonlat(cell)
#> <wk_xy[1] with CRS=OGC:CRS84>
#> [1] (-3.280745 56.43135)
# Data frame output
cell2 <- a5_lonlat_to_cell(114.8, 4.1, resolution = 5)
a5_cell_to_lonlat(cell2, as_dataframe = TRUE)
#> lon lat
#> 1 114.9474 4.191425
