as.points: Conversion to a SpatVector of points

as.pointsR Documentation

Conversion to a SpatVector of points

Description

Conversion of a SpatRaster, SpatVector or SpatExtent to a SpatVector of points.

Usage

## S4 method for signature 'SpatRaster'
as.points(x, values=TRUE, na.rm=TRUE, na.all=FALSE)

## S4 method for signature 'SpatVector'
as.points(x, multi=FALSE, skiplast=TRUE)

## S4 method for signature 'SpatExtent'
as.points(x, crs="")

Arguments

x

SpatRaster, SpatVector or SpatExtent

values

logical; include cell values as attributes?

multi

logical. If TRUE a multi-point geometry is returned

skiplast

logical. If TRUE the last point of a polygon (which is the same as the first point) is not included

na.rm

logical. If TRUE cells that are NA are ignored

na.all

logical. If TRUE cells are only ignored if na.rm=TRUE and their value is NA for all layers instead of for any layer

crs

character. The coordinate reference system (see crs)

Value

SpatVector

See Also

as.lines, as.points

Examples

r <- rast(ncols=2, nrows=2)
values(r) <- 1:ncell(r)

as.points(r)

if  (gdal() >= "3.0.0") {
	p <- as.polygons(r)
	as.points(p)
}

terra documentation built on Oct. 14, 2024, 5:07 p.m.