File: setExtent.Rd

package info (click to toggle)
r-cran-raster 3.6-31-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,300 kB
  • sloc: cpp: 2,367; ansic: 1,572; sh: 13; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,294 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
\name{setExtent}

\alias{setExtent}
\alias{extent<-}
  
\title{Set the extent of a RasterLayer}

\description{
setExtent sets the extent of a Raster* object. Either by providing a new Extent object or by setting the extreme
coordinates one by one.
}

\usage{
setExtent(x, ext, keepres=FALSE, snap=FALSE)
extent(x) <- value
}

\arguments{
  \item{x}{A Raster* object}
  \item{ext}{ An object of class Extent (which you can create with \code{\link[raster]{extent}}, or an object that has an extent (e.g. a Raster* or Spatial* object) ) }   
  \item{keepres}{logical. If \code{TRUE}, the resolution of the cells will stay the same after adjusting the bounding box (by adjusting the number of rows and columns). 
  If \code{FALSE}, the number of rows and columns will stay the same, and the resolution will be adjusted.
}
  \item{snap}{logical. If \code{TRUE}, the extent is adjusted so that the cells of the input and output RasterLayer are aligned}
  \item{value}{An object of class Extent (which you can create with \code{\link[raster]{extent}} )}  
}


\value{
a Raster* object
}
  


\seealso{  \code{\link[raster]{extent}}, \code{\link[raster]{Extent-class}} }

\examples{
r <- raster()
bb <- extent(-10, 10, -20, 20)
extent(r) <- bb
r <- setExtent(r, bb, keepres=TRUE)

}

\keyword{spatial}