The FFT package is meant to provide a connection to a Java library that implements forest-related models in the French context. At the moment, three features are available through the FFT package:
To properly work, the FFT package requires the installation of the J4R package, which ensures the connection to Java. Please see the J4R webpage for more information about the installation of J4R and its requirements.
First, make sure that the J4R package has been installed on your computer. To do this, please read the installation of the J4R webpage.
The FFT is available for Linux and Windows. The following line of command will download and install the latest version of the package:
> install.packages("https://sourceforge.net/projects/lerfobforesttools/files/FFT_1.0.0.tar.gz", repos = NULL, type="source")
Installing package into ‘/home/donenrique/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
trying URL 'https://sourceforge.net/projects/lerfobforesttools/files/FFT_1.0.0.tar.gz'
Content type 'application/x-gzip' length 7238350 bytes (6.9 MB)
==================================================
downloaded 6.9 MB
* installing *source* package ‘FFT’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (FFT)
>
A complete description of the model as well as its Java implementation can be found on this webpage. In R, the model of height-diameter relationships is created through the following function:
> hdPredictor <- createHDPredictor()
Starting Java server...
Parameters received:-firstcall; true; -ext; /home/fortin/R/x86_64-pc-linux-gnu-library/3.4/FFT;
Language set to: English
Launching RGateway Server...
ClassPath = -cp repicea.jar:/home/fortin/R/x86_64-pc-linux-gnu-library/3.4/FFT/*
No parameters received.
Server starting
Connecting on port 18011
[1] "Instantiating the model of HD relationships..."
[1] "Done."
>
An example of data.frame object that contains trees from the French National Forest Inventory (NFI) can be retrieved as follows:
> dataEx <- FFT::subsetNFI
> View(dataEx)
>
We can select the first plot of the data.frame object for the sake of the example:
> myPlot <- dataEx[which(dataEx$idp == 1000001),]
The main function is getTreeHeightsForThisPlot. It requires the following arguments:
Argument | Description |
---|---|
hdPredictor | the java.object instance that represents the model of HD relationships |
data | a data.frame object that contains all the trees of a particular plot |
idField | the name of the field that contains the plot id |
slopeInclinationField | the name of the field that contains the slope inclination in percent |
xcoordField | the name of the field that contains the longitude in geographical coordinates |
ycoordField | the name of the field that contains the latitude in geographical coordinates |
hasBeenHarvestedField | the name of the field that contains a logical (TRUE if the plot has been harvested in the last five years) |
basalAreaField | the name of the field that contains the plot basal area (m2/ha) |
mqdField | the name of the field that contains the plot mean quadratic diameter (cm) |
dbhField | the name of the field that contains the diameter at breast height (DBH, cm) |
speciesField | the name of the field that contains the species name (see the common name in this table) |
Given the field names in our data.frame object, the predicted heights can be generated as follows:
> myPlot$predM <- getTreeHeightsForThisPlot(hdPredictor,
myPlot,
idField = "idp",
slopeInclinationField = "slope",
xcoordField = "xcoord",
ycoordField = "ycoord",
hasBeenHarvestedField = "harvested",
basalAreaField = "basalAreaM2Ha",
mqdField = "mqdCm",
dbhField = "dbhCm",
speciesField = "speciesName")
>
CAT is a carbon accounting tool for managed forest. Please see the CAT home page for a complete description of the tool. The FFT package allows for a connection to this tool. The user can:
CAT is instantiated from R through the openCAT function as follows:
> library(FFT)
Welcome to FFT!
The FFT package implements some biometric models applied to French forests!
Please, make sure that Java (version 8 or greater) is part of the path and
that the J4R package has been installed on your computer.
For more information, visit https://sourceforge.net/p/lerfobforesttools/wiki/FFT/ .
> openCAT()
Starting Java server...
Parameters received:-firstcall; true; -ext; /home/fortin/R/x86_64-pc-linux-gnu-library/3.4/FFT;
Language set to: English
Launching RGateway Server...
ClassPath = -cp repicea.jar:/home/fortin/R/x86_64-pc-linux-gnu-library/3.4/FFT/*
No parameters received.
Server starting
Connecting on port 18011
[1] "Opening CAT application..."
[1] "Done."
>
CAT's splashwindow should pop up followed by the license agreement.
After accepting the license, CAT's main window should be displayed:
Shutting down the Java server through the shutdownJava function will terminate the CAT application as well.
CAT expects to be sent data from a data.frame instance. This data.frame object should actually contain a growth simulation. An example of such a data.frame object is already available in the FFT package:
> mySimulationData <- FFT::subsetMathilde
> View(mySimulationData)
>
The field names do not matter much. Actually, CAT needs some information and the R function that sends the data to CAT makes it possible to specify the field that contained the appropriate information. This function is called exportDatasetToCAT and it requires the following arguments:
Argument | Description |
---|---|
importName | the name of the import |
dataSet | a data.frame object that contains the simulation |
yearField | the name of the field that contains the date |
realizationField | the name of the field that contains the realization id |
plotIdField | the name of the field that contains the plot id |
plotAreaField | the name of the field that contains the plot area (ha) |
statusField | the name of the field that contains the tree status (alive, cut, windthrow or dead) |
volumeDm3Field | the name of the field that contains the tree volume (Dm3) |
numberOfTreesField | the name of the field that contains the expansion factor, i.e. the number of trees in the plot (NOT per hectare) represented by this record |
speciesField | the name of the field that contains the species name |
dbhField | the name of the field that contains the dbh (cm) |
With the above data.frame object, the function could be called as follows:
> exportDatasetToCAT("myDataFromR",
+ mySimulationData,
+ "Year",
+ "IterMC",
+ "PlotID",
+ "PlotAreaHa",
+ "Status",
+ "Vol_dm3",
+ "Number",
+ "Species",
+ "DBHcm")
[1] "Exporting realization 0 plot 1000054 year 2015"
[1] "Exporting realization 0 plot 1000054 year 2020"
[1] "Exporting realization 0 plot 1000054 year 2025"
[1] "Exporting realization 0 plot 1000054 year 2030"
[1] "Exporting realization 0 plot 1000054 year 2035"
[1] "Exporting realization 0 plot 1000054 year 2040"
...
When the export is over, the user is prompt twice in CAT. The first time is to match all the species that were found in the data.frame object with those recognized in CAT:
The second prompt is to confirm the import of the stand list in CAT:
CAT can now simulate the carbon balance of this stand list. This can be done through CAT user interface. Further details about the different options for simulating the carbon balance can be found in the CAT home page.
Once the simulation has been carried out, the results can be retrieved from R as follows
> export <- getExportedRecordSets()
>
The export object is actually a list of data.frame objects that corresponds to the export formats shown in CAT - User interface webpage. CAT can now be shutted down manually through the user interface or simply be disconnecting from the Java gateway server as follows:
> shutdownJava()
[1] "Removing the CAT application from the cache..."
Closing connection and removing socket...
Shutting down application...
Done.
>
The simulation results can now be easily plotted as in the following example:
> require(ggplot2)
Loading required package: ggplot2
> evolution <- export$CarbonStockAndFluxEvolution
> ggplot() +
+ geom_line(aes(y=tCHaMean, x=Year, col=Compart), data=evolution)
>
A complete description of the model of plot-level harvest occurrence can be found on this webpage.
To be completed...
Date | Version released | Features and bugs fixed | Comments |
---|---|---|---|
2020-03-13 | 1.0.0 | Fully compatible with Java 8, 11 and 13 and upgrade to J4R 1.0.5 | |
2020-01-17 | 0.2.2 | Upgrade to J4R 1.0.4 | |
2019-07-24 | 0.2.1 | Upgrade to J4R 1.0.1 and CAT 1.1 | |
2019-04-16 | 0.2.0 | First beta version |