Learn R Programming

siland (version 3.0.2)

landtoraster: Transformation of an sf object into raster

Description

Function transforming an object of class sf into raster (points grid) with wd, the pixel size of the raster. landname gives the variable names for which raster points have to be computed.

Usage

landtoraster(landgis, landname, wd)

Value

a list of dataframes. The components of the list correspond to variables specifed in argument landname. Each dataframe gives the X and Y locations of pixels in raster.

Arguments

landgis

an object of class sf

landname

vector of names of landscape variable for which rasters are computed.

wd

numeric, pixels size of raster

Author

O. Martin

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
# \donttest{
data(dataSiland)
data(landSiland)
head(dataSiland)
head(landSiland)
u=landtoraster(landSiland,c("L1","L2"),wd=20)
names(u)
du1=as.data.frame(raster::rasterToPoints(u[[1]]))
du2=as.data.frame(raster::rasterToPoints(u[[2]]))
plot(du1[,1:2],type="n")
sel1=du1[,3]==1
sel2=du2[,3]==1
points(du1[sel1,c(1,2)],pch=".",col=1)
points(du2[sel2,c(1,2)],pch=".",col=2)


# }

Run the code above in your browser using DataLab