View source: R/create_stars_raster.R
create_stars_raster | R Documentation |
stars
rasterThe use of a template enables the creation of an accurate raster, even in the presence of NAs.
create_stars_raster(template, nx, ny, data, var)
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. |
A stars
object.
st_as_stars
, st_rasterize
# 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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.