Description Usage Arguments Details Value Author(s) Examples
Functions to extract values of raster image from given location, specified by coordinates in raster projection, by cell position or by geogpaphical coordinates. Additional utils to convert cell position and planar coordinates mutually.
1 2 3 4 5 6 7 8 9 |
obj |
Object of class | ||||||||||||||||||||||||||||||||
... |
the set of argumetns, which are recognized via their names (using regular expressions) and classes:
|
value_xy
returns values for location, which is specified by planar coordinates (x, y).
value_cr
returns values for location, which is specified by cell posisition (column, row) relative to upper-left corner of image .
value_ll
returns values for location, which is specified by longitude and latitude (long, lat).
coord_xy
transforms planar coordinates (x, y) to cell position (column, row).
coord_cr
transforms cell position (column, row) to planar coordinates (x, y).
It is required to use a couple of coordinate vectors: (x, y)
, (c, r)
or (lon, lat)
of the same length. The unary argument is interpreted as index in internal value storage.
Position in column/row coordinates starts from upper-lever corner. The cell of upper-level corner has (1, 1) coordinates (in R indices starts from 1L
), whereas in some GIS the same corner cell has (0, 0) coordinates.
The column names of returned matrix are character format of index in internal value storage. This index can be specify in any function as argument ind
instead of coordinates (planar, geographical, cell position).
For value.*
numeric matrix of raster values. Band values for specific coordinates are by column. Set of specific coordinates are by row. rownames
are band names, and colnames
are index in internal value storage.
For coord.*
numeric matrix of coordinates with a vector of couple coordinates, one coordinate per one row. rownames
are returned coordinates, and colnames
are index in internal value storage.
Nikita Platonov platonov@sevin.ru
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 | session_grid(NULL)
set.seed(352)
a <- as.integer(ursa_dummy(3,min=0,max=999))
ind <- which(ursa_value(a[1])==890)
print(ind)
msk <- a[1]==890
am <- a[msk]
b <- as.data.frame(am)
b$jx <- b$x+runif(nrow(b),min=-1000,max=1000)
b$jy <- b$y+runif(nrow(b),min=-1000,max=1000)
print(b)
cr1 <- coord_xy(a,x=b$jx,y=b$jy)
cr2 <- coord_xy(a,y=b$y,x=b$x)
cr3 <- coord_xy(a,ind=ind)
print(cr1)
print(all.equal(cr1,cr2,cr3))
xy1 <- coord_cr(a,c=cr1["c",],r=cr1["r",])
print(xy1)
print(c(identical(unname(xy1["x",]),b[,"x",drop=TRUE])
,identical(unname(xy1["y",]),b[,"y",drop=TRUE])))
val1 <- value_xy(a,x=b$jx,y=b$jy)
val2 <- value_xy(a,x=b$x,y=b$y)
val3 <- value_cr(a,ind=ind)
val4 <- value_cr(a,c=cr1["c",],r=cr1["r",])
print(val1)
print(all.equal(val1,val2,val3,val4))
ps <- pixelsize()
ll <- c(lon=180,lat=70)
v <- value_ll(ps,lon=180,lat=70)
print(c('True scale'=v/with(ursa_grid(ps),1e-6*resx*resy)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.