check_grid_coverage: Calculate the grid coverage statistics for polygons

View source: R/spatial.R

check_grid_coverageR Documentation

Calculate the grid coverage statistics for polygons

Description

Calculate the grid coverage statistics for polygons

Usage

check_grid_coverage(grid_data, polygons, polygon_id_cols = NULL)

Arguments

grid_data

Data frame with longitude and latitude columns

polygons

sf object with polygon geometries

polygon_id_cols

Column names that identify the polygons

Value

A list with elements total_polygons, total_grid_points, polygons_with_points, polygons_without_points, coverage_percent, points_per_polygon (a data.frame of polygon identifiers and n_points) and summary (a one-line character description).

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)
check_grid_coverage(grid, polys)

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