| visualize_grid_overlap | R Documentation |
Show the overlap of grid points and polygons
visualize_grid_overlap(
grid_data,
polygons,
show_centroids = TRUE,
grid_color = "#E74C3C",
polygon_fill = NA,
polygon_color = "#2C3E50",
centroid_color = "#3498DB",
title = "Grid-Polygon Overlap"
)
grid_data |
Data frame with longitude and latitude columns, or the path to a NetCDF or CSV file |
polygons |
sf object, or the path to a GeoJSON file |
show_centroids |
Logical. If TRUE, show the polygon centroids |
grid_color |
Color for grid points |
polygon_fill |
Fill color for polygons |
polygon_color |
Border color for polygons |
centroid_color |
Color for centroids |
title |
Plot title |
ggplot object
grid <- expand.grid(longitude = seq(72.5, 77.5, by = 1), latitude = seq(18.5, 21.5, by = 1))
grid$temperature <- seq_len(nrow(grid))
cells <- sf::st_make_grid(sf::st_as_sfc(sf::st_bbox(
c(xmin = 72, ymin = 18, xmax = 78, ymax = 22),
crs = 4326
)), n = c(2, 1))
polys <- sf::st_sf(region = c("west", "east"), geometry = cells)
visualize_grid_overlap(grid, polys)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.