File: select.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 (73 lines) | stat: -rw-r--r-- 1,737 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
\name{select}

\docType{methods}

\alias{select}
\alias{select,Raster-method}
\alias{select,Spatial-method}

\title{
Geometric subsetting
}

\description{
Geometrically subset Raster* or Spatial* objects by drawing on a plot (map).
}


\usage{
\S4method{select}{Raster}(x, use='rec', ...)

\S4method{select}{Spatial}(x, use='rec', draw=TRUE, col='cyan', size=2, ...)
}

\arguments{
\item{x}{Raster*, SpatialPoints*, SpatialLines*, or SpatialPolygons*}
\item{use}{character: 'rec' or 'pol'. To use a rectangle or a polygon for selecting}
\item{draw}{logical. Add the selected features to the plot?}
\item{col}{color to use to draw the selected features (when \code{draw=TRUE)}}
\item{size}{integer > 0. Size to draw the selected features with (when \code{draw=TRUE)})}
\item{...}{additional arguments. None implemented}
}

\seealso{
\code{\link{click}, \link{crop}}
}


\value{
Raster* or Spatial* object
}


\examples{
\dontrun{

# select a subset of a RasterLayer
r <- raster(nrow=10, ncol=10)
values(r) <- 1:ncell(r)
plot(r)
s <- select(r) # now click on the map twice

# plot the selection on a new canvas:
x11()
plot(s)


# select a subset of a SpatialPolygons object
p1 <- rbind(c(-180,-20), c(-140,55), c(10, 0), c(-140,-60), c(-180,-20))
hole <- rbind(c(-150,-20), c(-100,-10), c(-110,20), c(-150,-20))
p2 <- rbind(c(-10,0), c(140,60), c(160,0), c(140,-55), c(-10,0))
p3 <- rbind(c(-125,0), c(0,60), c(40,5), c(15,-45), c(-125,0))
pols <- SpatialPolygons( list(  Polygons(list(Polygon(p1), Polygon(hole)), 1),
      Polygons(list(Polygon(p2)), 2), Polygons(list(Polygon(p3)), 3)))
pols@polygons[[1]]@Polygons[[2]]@hole <- TRUE

plot(pols, col=rainbow(3))
ps <- select(pols) # now click on the map twice
ps
}
}

\keyword{spatial}