briskaR Demonstrations

Jean-fran├žois Rey and Samuel Soubeyrand

2017-09-04

Landscape

Commands to load and display a real landscape

## Set briskaR working intern projection to LAMBERT 93 (default)
briskaRSetInternProjection(LAMBERT_93)

## load the maize_65 data set incorporated in briskaR
## in which polygons are either maize or non-maize fields
data(maize_65)

## then, randomly assign the GMO and non-GMO marks to maize fields
## non-maize fields being considered as receptors
initial_types=maize_65@thelandscape@data
nb_maize=sum(initial_types[,1])
nb_non_maize=sum(initial_types[,2])
types=as.data.frame(cbind(0,NA,initial_types[,2]))
names(types)=c("sources","neutral","receptors")
GM_fields=sample((1:nrow(types))[initial_types[,1]==1],
0.4*(nb_maize+nb_non_maize),replace=FALSE)
types[GM_fields,1]=1
types[,2]=1*(types[,1]==0 & types[,3]==0)

## generate land1 with the new marks for polygons
land1=maize_65
land1@thelandscape@data=types

## transform receptors at the border of the study domain
## into neutral cells
border_size=200
for(i in 1:land1@n){
  if(land1@thelandscape@data[i,3]==1){
    x0=land1@thelandscape@polygons[[i]]@Polygons[[1]]@coords
    if(sum(x0[,1]<land1@xmin+border_size | x0[,1]>land1@xmax-border_size |
      x0[,2]<land1@ymin+border_size | x0[,2]>land1@ymax-border_size)>0){
      land1@thelandscape@data[i,3]=0
      land1@thelandscape@data[i,2]=1
    }
  }
}
## display the landscape
plot(land1)

Commands to generate and display a simulated landscape:

## generate the Voronoi tesselation
land=simulateInitialPartition(n=200, prop=0.4, range=10,
xmin=0, xmax=5000, ymin=0, ymax=5000)
## generate receptors at the borders of Voronoi cells
land2=simulateThickMargins(land, border_size=200, prob=0.5,
mean_thickness=5, v_thickness=50)
## display the landscape
plot(land2)

Individuals

Commands to generate and display exposed individuals for the real landscape land1:

## tuning parameters and variables
nb_ind=100 ; time_min=1 ; time_max=61
birth_dates=sample(time_min:time_max, size=nb_ind, replace=TRUE)
life_expectancies=rep(20, nb_ind)
toxic_gap=rep(15, nb_ind)
## generate exposed individuals
ind=simulateIndividuals(land1, n=nb_ind, mintime=time_min,
                        maxtime=time_max, dob=birth_dates,
            life_duration=life_expectancies, toxic_threshold=toxic_gap)
## plot individuals in the landscape
plot(land1,ind)