rflsgen
Neutral landscape generator that allows users to set targets on landscape indices.
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
○codemeta.json file
-
○.zenodo.json file
-
✓DOI references
Found 2 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (15.2%) to scientific vocabulary
Repository
Neutral landscape generator that allows users to set targets on landscape indices.
Basic Info
- Host: GitHub
- Owner: dimitri-justeau
- Language: R
- Default Branch: master
- Homepage: https://dimitri-justeau.github.io/rflsgen/
- Size: 61.8 MB
Statistics
- Stars: 13
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
rflsgen 
Neutral Landscape Generator with Targets on Landscape Indices
Logo by Camille Salmon
rflsgen is the R distribution of flsgen, a neutral landscape generator that allows users to set targets on landscape indices. It first relies on Choco-solver to identify landscape structure satisfying user targets, then uses a stochastic algorithm to produce landscape rasters.
For more details and tutorials, please visit rflsgen's website: https://dimitri-justeau.github.io/rflsgen/
Download and installation
Java 8+ must be installed in your system to run rflsgen. Download and installation instructions for Java are available here: https://www.oracle.com/java/technologies/javase-downloads.html, or here: https://openjdk.java.net/install/. To provide an R interface to flsgen, which is written in Java, rflsgen relies on rJava, which is a dependency of rflsgen and will be installed automatically. If you have any trouble during the installation of rflsgen due to rJava, please refer to rJava's documentation: https://rforge.net/rJava/index.html.
rflsgen is available on CRAN, so you can install it from R using the following command:
install.packages("rflsgen")
library(rflsgen)
To install rflsgen from Github, you can use the devtools library (https://www.r-project.org/nosvn/pandoc/devtools.html) and use the following commands in R:
r
devtools::install_github("dimitri-justeau/rflsgen")
library(rflsgen)
Quickstart
Generating a fractal terrain raster
You can easily generate a fractal terrain raster using the flsgen_terrain function. For example, if you want to generate a 200x200 fractal terrain with default parameters, use the following command:
r
terrain <- flsgen_terrain(200, 200)
plot(terrain)

Generating landscape structures from targets
Say that we want to generate a landscape structure for a 200x200 landscape containing three landscape classes (plus a non focal class), with the following user targets:
| Class | NP | AREA | CA | MESH | PLAND | | ----- |---------| ----------- |------------- |------| ----- | | 0 | [1, 10] | [300, 4000] | [1000, 5000] | 225 | - | | 1 | [2, 8] | [200, 4000] |- |- | 40% | | 2 | [5, 7] | [800, 1200] |- |- | - |
The first possibility is to create a JSON file (e.g. target.json) describing these targets (note that you can also store this json in a string variable):
json
{
"nbRows" : 200,
"nbCols" : 200,
"classes" : [
{
"name" : "Class A",
"NP" : [1, 10],
"AREA" : [300, 4000],
"CA" : [1000, 5000],
"MESH" : [225, 225]
},
{
"name" : "Class B",
"NP" : [2, 8],
"AREA" : [200, 4000],
"PLAND" : [40, 40]
},
{
"name" : "Class C",
"NP" : [5, 7],
"AREA" : [800, 1200]
}
]
}
The second possibility is to use rflsgen helper functions:
r
cls_a <- flsgen_create_class_targets(
"Class A",
NP = c(1, 10),
AREA = c(300, 4000),
CA = c(1000, 5000),
MESH = c(225, 225)
)
cls_b <- flsgen_create_class_targets(
"Class B",
NP = c(2, 8),
AREA = c(200, 4000),
PLAND = c(40, 40)
)
cls_c <- flsgen_create_class_targets(
"Class C",
NP = c(5, 7),
AREA = c(800, 1200)
)
ls_targets <- flsgen_create_landscape_targets(
nb_rows = 200,
nb_cols = 200,
classes = list(cls_a, cls_b, cls_c)
)
Using the flsgen_structure function, you can generate a non-spatially-explicit landscape structure:
r
structure <- flsgen_structure(targets_file = "examples/targets.json")
or
r
structure <- flsgen_structure(ls_targets)
The result is a JSON-formatted string that contains the generated structure. It can be easily converted into a data frame with a dedicated library such as jsonlite.
Generating landscape rasters from landscape structures
Now, let's generate a landscape raster from the previously generated structure. To do so, we use the flsgen_generate function to generate a landscape raster from the previously generated landscape structure:
r
landscape <- flsgen_generate(structure_str = structure)
plot(landscape)

Masking
It is possible to use a mask raster, whose NO_DATA cell will be unavailable for both focal and non-focal classes. To do so, instead of specifying the number of rows and columns in the targets, specify the mask raster with the maskRasterPath key:
json
{
"maskRasterPath": "mask.tif"
"classes" : [
{
"name" : "Class A",
"NP" : [2, 30],
"AREA" : [200, 4000],
"PLAND" : [40, 40]
}
]
}
or:
r
cls_a <- flsgen_create_class_targets(
"Class A",
NP = c(2, 30),
AREA = c(200, 4000),
PLAND = c(40, 40)
)
ls_targets <- flsgen_create_landscape_targets(
mask_raster = "mask.tif",
classes = list(cls_a)
)
Extracting structures from existing landscapes
Instead of generating landscape structure from targets, it is also possible to extract existing structures from real landscapes and use them to recreate real composition patterns. To do so, simply use the flsgen_extract_structure_from_raster function, indicating the raster values of focal classes:
r
struct <- flsgen_extract_structure_from_raster("existing_raster.tif", focal_classes=c(0, 1))
Citation
Please cite the rflsgen R package when using it in publications.
Justeau-Allaire, D., Blanchard, G., Ibanez, T., Lorca, X., Vieilledent, G. & Birnbaum, P. (2022). Fragmented landscape generator (flsgen): A neutral landscape generator with control of landscape structure and fragmentation indices. Methods in Ecology and Evolution, 00, 1– 9. https://doi.org/10.1111/2041-210X.13859
Owner
- Name: Dimitri Justeau-Allaire
- Login: dimitri-justeau
- Kind: user
- Repositories: 8
- Profile: https://github.com/dimitri-justeau
GitHub Events
Total
- Watch event: 2
Last Year
- Watch event: 2
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Dimitri | d****u@g****m | 104 |
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 3
- Total pull requests: 0
- Average time to close issues: 23 days
- Average time to close pull requests: N/A
- Total issue authors: 3
- Total pull request authors: 0
- Average comments per issue: 6.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- Mbinford (1)
- mingatgithub (1)
- CeresBarros (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 346 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 7
- Total maintainers: 1
cran.r-project.org: rflsgen
Neutral Landscape Generator with Targets on Landscape Indices
- Homepage: https://dimitri-justeau.github.io/rflsgen/
- Documentation: http://cran.r-project.org/web/packages/rflsgen/rflsgen.pdf
- License: GPL-3
-
Latest release: 1.2.2
published about 2 years ago
Rankings
Maintainers (1)
Dependencies
- rJava * depends
- raster * depends
- checkmate * imports
- jsonlite * imports
- rgdal * imports
- utils * imports
- knitr * suggests
- landscapemetrics * suggests
- rmarkdown * suggests
- testthat >= 3.0.0 suggests
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/setup-java v1 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/setup-java v1 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- actions/checkout v2 composite
- actions/setup-java v1 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/setup-java v1 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite