tz_lookup: Lookup time zones of sf or sp points

View source: R/tz_lookup.R

tz_lookupR Documentation

Lookup time zones of sf or sp points


There are two methods - "fast", and "accurate". The "fast" version can look up many thousands of points very quickly, however when a point is near a time zone boundary and not near a populated centre, it may return the incorrect time zone. If accuracy is more important than speed, use method = "accurate".


tz_lookup(x, crs = NULL, method = "fast", warn = TRUE)



either an sfc or sf points or SpatialPoints(DataFrame) object


the coordinate reference system: integer with the EPSG code, or character with proj4string. If not specified (i.e., NULL) and x has no existing crs, EPSG: 4326 is assumed (lat/long).


method by which to do the lookup. Either "fast" (default) or "accurate".


By default, if method = "fast" a warning is issued about the potential for inaccurate results. Set warn to FALSE to turn this off.


Note that there are some regions in the world where a single point can land in two different overlapping time zones. The "accurate" method includes these, and when they are encountered they are concatenated in a single string, separated by a semicolon. The data used in the "fast" method does not include overlapping time zones at this time.


character vector the same length as x specifying the time zone of the points.


if (require("sf")) {

state_pts <- lapply(seq_along($x), function(i) {

state_centers_sf <- st_sf(st_sfc(state_pts))

state_centers_sf$tz <- tz_lookup(state_centers_sf)

plot(state_centers_sf[, "tz"])

lutz documentation built on Oct. 18, 2023, 1:17 a.m.