Examples for 'terra::$'


Get or replace attribute values of a SpatVector

Aliases: $ $<- $,SpatVector-method $<-,SpatVector-method [[,SpatVector,numeric,missing-method [[,SpatVector,logical,missing-method [[,SpatVector,character,missing-method [[<-,SpatVector,character,missing-method [[<-,SpatVector,numeric,missing-method [<-,SpatVector,ANY,ANY-method [<-,SpatVector,ANY,missing-method [<-,SpatVector,missing,ANY-method

Keywords: spatial

### ** Examples

f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
v$NAME_1
 [1] "Diekirch"     "Diekirch"     "Diekirch"     "Diekirch"     "Diekirch"    
 [6] "Grevenmacher" "Grevenmacher" "Grevenmacher" "Luxembourg"   "Luxembourg"  
[11] "Luxembourg"   "Luxembourg"  
v$NAME_1[3] <- "my name"
v$ID_1 <- LETTERS[1:12]
v$new <- sample(12)
values(v)
   ID_1       NAME_1 ID_2           NAME_2 AREA    POP new
1     A     Diekirch    1         Clervaux  312  18081   4
2     B     Diekirch    2         Diekirch  218  32543  12
3     C      my name    3          Redange  259  18664   8
4     D     Diekirch    4          Vianden   76   5163  11
5     E     Diekirch    5            Wiltz  263  16735  10
6     F Grevenmacher    6       Echternach  188  18899   7
7     G Grevenmacher    7           Remich  129  22366   6
8     H Grevenmacher   12     Grevenmacher  210  29828   5
9     I   Luxembourg    8         Capellen  185  48187   2
10    J   Luxembourg    9 Esch-sur-Alzette  251 176820   9
11    K   Luxembourg   10       Luxembourg  237 182607   3
12    L   Luxembourg   11           Mersch  233  32112   1
v[2,2] <- "hello"
v[1,] <- v[10,]
v[,3] <- v[,1]
v[2, "NAME_2"] <- "terra"
head(v, 3)
  ID_1     NAME_1 ID_2           NAME_2 AREA    POP new
1    J Luxembourg    J Esch-sur-Alzette  251 176820   9
2    B      hello    B            terra  218  32543  12
3    C    my name    C          Redange  259  18664   8

[Package terra version 1.5-34 Index]