Set or get metadata
metags.Rd
You can set arbitrary metadata to (layers of) a SpatRaster using "name=value" tags. When wring a SpatRaster to a GTiff file, these tags are written to file.
Usage
# S4 method for class 'SpatRaster'
metags(x, layer = NULL) <- value
# S4 method for class 'SpatRaster'
metags(x, layer=NULL, name=NULL)
# S4 method for class 'SpatRasterDataset'
metags(x, dataset = NULL) <- value
# S4 method for class 'SpatRasterDataset'
metags(x, dataset=NULL, name=NULL)
Arguments
- x
SpatRaster
- layer
NULL, positive integer or character. If the value is NULL, the tags assigned or returned are for the SpatRaster. Otherwise for the layer number(s) or name(s)
- name
character
- value
character of "name=value" or two-column matrix
- dataset
NULL, positive integer or character. If the value is NULL, the tags assigned or returned are for the SpatRasterDataset/SpatRasterCollection. Otherwise for the datset number(s) or name(s)
Examples
r <- rast(ncol=5, nrow=5)
m <- cbind(c("one", "two", "three"), c("ABC", "123", "hello"))
metags(r) <- m
metags(r)
#> one three two
#> "ABC" "hello" "123"
metags(r) <- c("another_tag=another_value", "one more=this value")
metags(r)
#> another_tag one one more three two
#> "another_value" "ABC" "this value" "hello" "123"
metags(r) <- c(another_tag="44", `one more`="that value")
metags(r)
#> another_tag one one more three two
#> "44" "ABC" "that value" "hello" "123"
metags(r, name="two")
#> two
#> "123"
# remove a tag
metags(r) <- cbind("one", "")
metags(r) <- "two="
metags(r)
#> another_tag one more three
#> "44" "that value" "hello"
# remove all tags
metags(r) <- NULL
metags(r)
#> named character(0)