visualize_grid_overlap: Show the overlap of grid points and polygons

View source: R/spatial.R

visualize_grid_overlapR Documentation

Show the overlap of grid points and polygons

Description

Show the overlap of grid points and polygons

Usage

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"
)

Arguments

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

Value

ggplot object

Examples


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)


varunayan documentation built on Oct. 30, 2026, 1:07 a.m.