make_grid: Sample Point Locations in a SpatialPolygon*

Description Usage Arguments Value Examples

View source: R/make_grid.R

Description

This is a wrapper around the sp::makegrid function, only for SpatialPolygon* objects.

Usage

1
make_grid(sppoly, n, ...)

Arguments

sppoly

SpatialPolygon* object as defined in the sp package.

n

approximate sample size.

...

optional arguments passed to sp::makegrid

Value

A SpatialPoints$ object. The length of the object is approximately equal to n.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(sf)
vn <- gadmVN::gadm(level = "country")
vn <- sf::as_Spatial(vn)
sp::plot(vn)
grid <- make_grid(vn, 100)
length(grid)
sp::plot(grid, add = TRUE)
grid2 <- make_grid(vn, cellsize = .5)
length(grid2)
sp::plot(grid2, add = TRUE, col = "blue")

choisy/sptools documentation built on Aug. 22, 2019, 12:57 p.m.