landtoraster: Transformation of an sf object into raster

View source: R/landtoraster.R

landtorasterR Documentation

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)

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

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.

Author(s)

O. Martin

Examples

##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

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)





siland documentation built on March 31, 2023, 7:33 p.m.