
Plot generated points on spatial input object
Source:R/1.2_function_array_generation.R
plot_points_on_input.Rd
Creates a visualization showing the generated points overlaid on the original spatial object (raster or polygon). Handles different input types automatically.
Arguments
- input_obj
A spatial object. Can be a RasterLayer, RasterBrick, RasterStack, sf/sfc object, or SpatialPolygons/SpatialPolygonsDataFrame.
- points_sf
An sf object containing the points to plot, typically generated by one of the point generation functions.
Value
A ggplot2 object showing the spatial input with points overlaid. For rasters, displays as a heatmap with color scale. For polygons, displays as filled shapes with points.
Details
The function automatically detects whether the input is a raster or polygon and creates an appropriate visualization. Point count and generation method information are included in the plot subtitle if available from the points_sf attributes.
Examples
if (FALSE) {
# Plot points on a raster
r <- raster::raster(matrix(1:100, 10, 10))
points <- generate_random_points(r, n_points = 50)
plot_points_on_input(r, points)
# Plot points on a polygon
poly <- sf::st_sfc(sf::st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)))))
points <- generate_spaced_points(poly, spacing = 0.2)
plot_points_on_input(poly, points)
}