create_stars_raster {quadkeyr} | R Documentation |
Create a stars
raster
Description
The use of a template enables the creation of an accurate raster, even in the presence of NAs.
Usage
create_stars_raster(template, nx, ny, data, var)
Arguments
template |
A |
nx |
Integer; number of cells in x direction. |
ny |
Integer; number of cells in y direction. |
data |
A |
var |
The column name of the variable to plot. |
Value
A stars
object.
See Also
Examples
# Basic workflow
# Read the data
path <- paste0(
system.file("extdata", package = "quadkeyr"),
"/cityA_2020_04_15_0000.csv"
)
data <- read.csv(path)
data <- format_fb_data(data)
complete_polygon_grid <- add_regular_polygon_grid(data = data)
stars_object <- create_stars_raster(
data = complete_polygon_grid$data,
template = complete_polygon_grid$data,
var = "percent_change",
nx = complete_polygon_grid$num_cols,
ny = complete_polygon_grid$num_rows
)
stars_object
# Other workflow
grid <- create_qk_grid(
xmin = -59,
xmax = -57,
ymin = -35,
ymax = -34,
zoom = 12
)
grid_coords <- get_qk_coord(data = grid$data)
polygrid <- grid_to_polygon(grid_coords)
data("data_provided")
data_raster <- polygrid |>
dplyr::inner_join(data_provided,
by = c("quadkey")
)
raster <- create_stars_raster(
template = data_raster,
nx = grid$num_cols,
ny = grid$num_rows,
data = data_raster,
var = "variable"
)
[Package quadkeyr version 0.1.0 Index]