1\name{copy} 2 3\docType{methods} 4 5\alias{copy} 6\alias{copy,SpatRaster-method} 7\alias{copy,SpatVector-method} 8 9 10\title{Deep copy} 11 12\description{ 13Make a deep copy of a SpatRaster or SpatVector. This is occasionally useful when wanting to use a replacement function in a shallow copy. That is a copy that was created like this: \code{x <- y}. If you use a replacement function to change an object, its shallow copies also change. 14} 15 16\usage{ 17\S4method{copy}{SpatRaster}(x) 18 19\S4method{copy}{SpatVector}(x) 20} 21 22\arguments{ 23 \item{x}{SpatRaster or SpatVector} 24} 25 26\value{ 27Same as \code{x} 28} 29 30 31\examples{ 32r <- rast(ncols=10, nrows=10, nl=3) 33tm <- as.Date("2001-05-03") + 1:3 34time(r) <- tm 35time(r) 36x <- r 37time(x) <- tm + 365 38time(x) 39time(r) 40 41y <- copy(r) 42time(y) <- tm - 365 43time(y) 44time(r) 45 46# or make a new object like this 47z <- rast(r) 48time(z) <- tm 49time(z) 50time(r) 51} 52 53 54\keyword{methods} 55\keyword{spatial} 56