Skip to contents

Change the vegetation density and height on each segment. The modification can be done on all banks or only on right or left banks.

Usage

TNET_modifyVeget(
  filename,
  density = NULL,
  height = NULL,
  density.left = NULL,
  density.right = NULL,
  height.left = NULL,
  height.right = NULL,
  select_ID = NULL
)

Arguments

filename

Path to the shapefile with all info on segments created by TNET_createShape(). It must contain the following columns:

\(gid\)ID of the Topage segment
\(vegPctL\)Percentage of the segment left bank length covered by vegetation (number between 0 and 100)
\(vegPctR\)Percentage of the segment right bank length covered by vegetation (number between 0 and 100)
\(vegHL\)Mean height of the vegetation on the segment left bank (in meter)
\(vegHR\)Mean height of the vegetation on the segment right bank (in meter)
density

expression (see details section). Set the new vegetation density on left and right banks.

height

expression (see details section). Set the new vegetation height on left and right banks.

density.left

expression (see details section). Set the new vegetation density on left bank only.

density.right

expression (see details section). Set the new vegetation density on right bank only.

height.left

expression (see details section). Set the new vegetation height on left bank only.

height.right

expression (see details section). Set the new vegetation height on right bank only.

select_ID

string or numerical vector Expression that select segments on which the modification will be set or a vector of gids to be affected by the vegetation modification.

Value

path to the shapefile created with modified vegetation and a unique filename based on realised calculation

Details

Height and density selection density, density.left and density.right expression must be one of the following (exemple on density argument, but work also on density.left and density.right arguments)

  • density = 30 : will set all vegetation density to 30%.

  • density = +30 : will add 30% of the segment length to the vegetation (60% will become 90%).

  • density = ++30: will add 30% of the vegetation density to the vegetation (60% will become 78%, because 0.3*60 = 18)

For height, height.left and height.right expression must be one of the following (exemple on height argument, but work also on height.left and height.right arguments)

  • height = 5 : will set all vegetation height to 5m.

  • height = +5 : will add 5m to all vegetation height (15m will become 20m).

  • height = ++5 : will add 5% of the vegetation height to the height (15m will become 15.75m, because 0.05*15 = 0.75)

Signs that can be use in the expression are + or ++ to add vegetation, and - or -- to remove vegetation.
density cannot be more than 100% and less than 0 and height cannont be less than 0.

Select_ID selection It's possible to affect Height and density changes only on selected segments. It's possible to select affected elements with an expression containing columns contain in filename shapefile (for exemple "OSTRAHL <= 2"). You can also give a vector of selected gid you want to change.

Examples

#reading shapefile 
filename = path/to/shapefile.shp
#> Error: object 'to' not found

st_read(filename)
#> Error in as.character(dsn) : 
#>   cannot coerce type 'closure' to vector of type 'character'
#> Error in st_read.default(filename): no st_read method available for objects of class function
#>          gid     vegPctL    vegPctR
#>1      540646  75.0560512  73.362396
#>2      918148  53.5128923  17.492715
#>3      748051  38.8304411  60.178841
#>4      686534  67.0719322  78.928194
#>5       23797  17.6317680  14.724709




### Put all vegetation density to 40% ###

new_filename = TNET_modifyVeget(filename,
                                density = 40)
#> Error in as.character(dsn) : 
#>   cannot coerce type 'closure' to vector of type 'character'
#> Error in st_read.default(filename, quiet = TRUE): no st_read method available for objects of class function

st_read(new_filename) 
#> Error: object 'new_filename' not found
#>          gid    vegPctL    vegPctR
#>1      540646         40         40
#>2      918148         40         40
#>3      748051         40         40
#>4      686534         40         40
#>5       23797         40         40




### add 30% of segment length to left bank if it's below 50% ###

new_filename = TNET_modifyVeget(filename,
                                density.left = +30,
                                select_ID = "vegPctL < 50")
#> Error in as.character(dsn) : 
#>   cannot coerce type 'closure' to vector of type 'character'
#> Error in st_read.default(filename, quiet = TRUE): no st_read method available for objects of class function

st_read(new_filename) 
#> Error: object 'new_filename' not found
#>          gid    vegPctL    vegPctR
#>1      540646   75.05605   73.36240
#>2      918148   53.51289   17.49271
#>3      748051   68.83044   60.17884
#>4      686534   67.07193   78.92819
#>5       23797   47.63177   14.72471




### remove 30% of segment length to the left bank       ###
### and add 20% of the vegetation density to right bank ###
### only on 540646 and 748051 segments                  ###

new_filename = TNET_modifyVeget(filename,
                                density.left = -30,
                                density.right = ++20,
                                select_ID = c(540646,748051))
#> Error in as.character(dsn) : 
#>   cannot coerce type 'closure' to vector of type 'character'
#> Error in st_read.default(filename, quiet = TRUE): no st_read method available for objects of class function

st_read(new_filename) 
#> Error: object 'new_filename' not found
#>          gid    vegPctL    vegPctR
#>1      540646  45.056051   88.03488
#>2      918148  53.512892   17.49271
#>3      748051   8.830441   72.21461
#>4      686534  67.071932   78.92819
#>5       23797  17.631768   14.72470




### if you use the function TNET_initializeSim()  you can save  ###
### the new shapefile path in the "shapeName" argument of the   ###
### infoSim list                                                ###

infoSim = TNET_initializeSim(...) #see TNET_initializeSim() documentation
#> Error: '...' used in an incorrect context

#Create the shapefile for TNET
TNET_createShape(infoSim$TOPAGE_shape, infoSim$shapeName)
#> Error: object 'infoSim' not found

#Modify the vegetation
infoSim$shapeName = TNET_modifyVeget(infoSim$shapeName,
                                     density.left = 50,
                                     density.right = 0)
#> Error: object 'infoSim' not found

st_read(infoSim$TOPAGE_shape) 
#> Error: object 'infoSim' not found
#>          gid    vegPctL    vegPctR
#>1      540646         50          0
#>2      918148         50          0
#>3      748051         50          0
#>4      686534         50          0
#>5       23797         50          0