The spatial twin of timescales::datetime_to_timeslice(): raw
observations enter the structure here. Each point is matched to the
region at geoframe (the atoms by default) whose geometry contains
it; points outside every region return NA. A point exactly on a
shared border is assigned to the first matching region in the
object's canonical order.
Usage
coords_to_region(x, gs, geoframe = NULL, coords = c("lon", "lat"), crs = 4326)Arguments
- x
An
sf/sfcobject of points, or a data.frame with coordinate columns.- gs
A
Geoscalewith geometry attached (seeattach_geometry_geoscale()).- geoframe
Geoframe to resolve to;
NULL(default) uses the finest geoframe.- coords
Names of the coordinate columns when
xis a plain data.frame (x/longitude first, y/latitude second).- crs
Coordinate reference system of those columns (default WGS84); points are transformed to the geometry's CRS before matching.
Examples
if (FALSE) { # \dontrun{
obs <- data.frame(lon = c(-21.9, -18.1), lat = c(64.1, 65.7), v = 1:2)
obs$region <- coords_to_region(obs, gs)
} # }
