
Connecting Landscapes (CoLa) Decision support system (DSS)
Increasing loss and fragmentation of habitats has resulted in an urgent need to identify areas for conservation that also maintain and enhance ecological connectivity of protected areas. The Connecting Landscapes (CoLa) toolkit integrates and enhances numerous landscape genetics and habitat connectivity tools (Landguth and Cushman 2010, Landguth et al. 2012) to aid in identifying connectivity conservation priorities and areas of potential human wildlife conflict.
The toolkit is supported by NASA Biological Diversity & Ecological Conservation program Grant No. 80NSSC21K1942 - Strengthening Natural Resource Management with New Protected Area Connectivity Tools, and was co-developed with the Wildlife Conservation Research Unit (WildCRU) of University of Oxford and the United States Forest Service (USFS) Rocky Mountain Research Station, USFS International Programs.
Primary inputs to the tools include habitat suitability layers or spatially explicit estimates of animal movement potential across different land use types (resistance layers), and population source points. When properly parameterized, the toolkit can generate estimates of population genetic structure, population density, core movement areas, and long-distance dispersal corridors.
For recent examples of how the individual tools have been used for wildlife research and conservation assessments see Kaszta et al. (2020a), Kaszta et al. (2020b), Zeller et al. (2021), Ash et al. (2023), Makwana et al. (2023).
>> References
-
Ash, E., Cushman, S., Kaszta, Ż., Landguth, E., Redford, T. and Macdonald, D.W., 2023. Female-biased introductions produce higher predicted population size and genetic diversity in simulations of a small, isolated tiger (Panthera tigris) population. Scientific Reports, 13(1), p.11199.
-
Kaszta, Ż., Cushman, S.A. and Macdonald, D.W., 2020a. Prioritizing habitat core areas and corridors for a large carnivore across its range. Animal Conservation, 23(5), pp.607-616.
-
Kaszta, Ż., Cushman, S.A., Htun, S., Naing, H., Burnham, D. and Macdonald, D.W., 2020b. Simulating the impact of Belt and Road initiative and other major developments in Myanmar on an ambassador felid, the clouded leopard, Neofelis nebulosa. Landscape Ecology, 35, pp.727-746.
-
Landguth, E.L. and Cushman, S., 2010. CDPOP: a spatially explicit cost distance population genetics program. Molecular ecology resources, 10(1), pp.156-161.
-
Landguth, E.L., Hand, B.K., Glassy, J., Cushman, S.A. and Sawaya, M.A., 2012. UNICOR: a species connectivity and corridor network simulator. Ecography, 35(1), pp.9-14.
-
Makwana, M., Vasudeva, V., Cushman, S.A. and Krishnamurthy, R., 2023. Modelling landscape permeability for dispersal and colonization of tigers (Panthera tigris) in the Greater Panna Landscape, Central India. Landscape Ecology, 38(3), pp.797-819.
-
Zeller, K.A., Schroeder, C.A., Wan, H.Y., Collins, G., Denryter, K., Jakes, A.F. and Cushman, S.A., 2021. Forecasting habitat and connectivity for pronghorn across the Great Basin ecoregion. Diversity and Distributions, 27(12), pp.2315-2329.
>> Contact
Write Patrick.Jantz@nau.edu or ig299@nau.edu (Ivan Gonzalez) for questions and suggestions
The diagram of the DSS elements
These results are the comparisson of the developed functions with existing software. You can see the results for several scenarios (# of pixels, # of points), in terms of RAM (GB) and time (minutes) spent for both softwares
Scenario table
Full details
Create surface resistance
Habitat 2 resistance parameters info
Description
Converts a given raster into a new one using a mathematical transformation function and numeric range. s2res.py in the command line, or s2res_py( ) in R
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
| Suitability surface | intif | String | File path to the input raster | |||
| Output raster file name | outtif | String | File path of the output surface resistance | |||
| Suitability input grid minimum value | minval | Numeric | The lower value on the input raster to cut off. Pixels with values under the given number will be ignored. In the front end/DSS the values are automatically derived from the input file. | |||
| Suitability input grid maximum value | maxval | Numeric | The upper value on the input raster to cut off. Pixels with values under the given number will be ignored. In the front end the values are automatically derived from the input file | |||
| Maximum resistance value | maxout | Numeric | This is the maximum resistance value after transformation from suitability. The default value is 100. The minimum value is set to 1. | |||
| Shape parameter | shape | Numeric | A statistical parameter that defines the transformation pattern between the input and output. The shape value determines the relationship between suitability and resistance. For a linear relationship, use a value close to 0, such as 0.01. Positive values result in a greater increase in resistance as suitability declines. This is appropriate for animals that are more sensitive to the matrix in between habitats. Negative values result in a lesser increase in resistance as suitability declines. This is appropriate for animals that are less sensitive to the matrix between habitats. The more positive or more negative, the greater the effect on the shape of the relationship. Values generally range between +10 and -10, 0 is not allowed. | |||
| No data value | nodata | Numeric | The no data value of the input file. For GeoTiffs, this is automatically determined. For text-based files like ASCII or RSG rasters, the user must input them. The default value is ‘None’. | |||
| Projection parameter | prj | String | Projection information in the case the input raster has no spatial projection. For GeoTiffs, this is automatically determined. For text-based files like ASCII or RSG rasters, the user must input them. Provide it as EPSG or ESRI string, e.g. “ESRI:102028”. The default value is ‘None’ |
Create points
Create points parameters info
Description
Simulates spatial points probabilistically given a raster and a range of pixel values. Pixels with higher values (Yes option)are more likely to be sampled. create_source_points.py in the command line or points_py( ) in R.
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
| Source points | inshp | String | File path to the point layer. Spatial point layer (any ORG driver), CSV (X, Y files), or *.xy file | |||
| Output point layer | outtif | String | File path to the output point layer. Written in ESRI Shapefile format. | |||
| Surface resistance | intif | String | File path to the input raster. Requires a projected file with square pixels. Not LonLat projection allowed | |||
| Minimum value | minval | Numeric | The lower value of the pixels in the raster to consider to simulate the points. | |||
| Maximum value | maxval | Numeric | The upper value of the pixels in the raster to consider to simulate the points. | |||
| Number of points | npoints | Numeric | Number of points to simulate. | |||
| Is it suitable? | issuit | String | ‘Yes’ (default) or ‘No’. Indicates if the provided raster [1] is suitability. If so, the script will likely sample higher value pixels. If ‘No’, will assume it is resistance and will sample more likely lower values | |||
| Update CRS | upcrs | String | Projection information in the case the input raster [1] has no spatial projection. For GeoTiffs, this is automatically determined. For text-based files like ASCII or RSG rasters, this must be input by the user. Provide it as EPSG or ESRI string e.g. “ESRI:102028”. Default value is ‘None’. |
Create Distance Matrix
Distance matrix 2 resistance parameters info
Description
Creates a dispersal resistance matrix among a set of points. create_cdmat.py in the command line or cdmat_py( ) in R.
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
|Source points | | inshp| | String| |File path to the point layer. Spatial point layer (any ORG driver), CSV (X, Y files), or *.xy file| | Surface resistance | |intif| | String| | File path to the input raster. Requires a projected file with square pixels. Not LonLat projection allowed| | | | | | | | | |Output csv file name | | outcsv| | String| | File path of the outputcsv matrix| | | | | | | | | |Max. dispersal distance in cost units| |maxdist| |Numeric| |This is the maximum resistance value after transformation from suitability. The default value is 100. The minimum value is set to 1.| |Number of cores| | ncores| | Numeric| | Number of CPU cores to run the analysis| |Projection parameter| |prj| |String| |Projection information in the case the input raster has no spatial projection. For GeoTiffs, this is automatically determined. For text-based files like ASCII or RSG rasters, the user must input them. Provide it as EPSG or ESRI string, e.g. “ESRI:102028”. The default value is ‘None’|
Create kernels
Kernels parameters info
Description
Creates a continuous surface of cumulative paths that connects a set of points. crk.py in the command line, or crk_py( ) in R.
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
| Source points | inshp | String | File path to the point layer. Spatial point layer (any ORG driver), CSV (X, Y files), or *.xy file | |||
| Surface resistance | intif | String | File path to the input raster. Requires a projected file with square pixels. Not LonLat projection allowed | |||
| Output raster filename | outtif | string | File path of the output raster layer written in GeoTiff format. | |||
| Max. dispersal distance in cost units | maxdist | Numeric | This is the maximum distance to consider when calculating kernels and should correspond to the maximum dispersal distance of the focal species. Values greater than this will be converted to 0 before summing kernels. For example, if the maximum dispersal distance of the focal species is 10 km, set this value to 10000. | |||
| Kernel shape | shape | Numeric | String. This determines how the probability of dispersal declines with distance from the focal point. ‘linear’ implements the function 1 - (1/dThreshold) * d * where dThreshold is the specified distance threshold and d is the distance from the focal point. ‘gaussian’ implements the function exp(-1*((d^2)/(2*(dispScale^2)))) where d is the distance from the focal point and dispScale is equal to dThreshold/4. In future versions, users will be able to specify dispScale. | |||
| Use transformation? | transf | String | ’yes’ or ‘no’. If it is set to ‘no’, then no kernel volume transformation is applied and the next argument [8] is ignored. If it is set to ‘yes’, then the value in argument volume [8] is used to transform the kernel volume. | |||
| Kernel volume | volume | Numeric | If 1, the default, the resistant kernel value at the origin is 1 and no kernel volume transformation is applied. If > 1, the parameter value is used to scale distance values by a constant that is determined by the equation kVol * 3/(pi*dThreshold^2) where kVol is the kernel volume parameter, dThreshold is the specified distance threshold, and pi is the mathematical constant pi. The constant is then multiplied by the distances to the focal point resulting in a scaled kernel volume. | |||
| Number of cores | ncores | Numeric | Number or cores of your computer to run the analysis | |||
| Projection string | crs | String | Projection information in the case the input raster [2] has no spatial projection. Provide it as EPSG or ESRI string e.g. “ESRI:102028”. Default value is ‘None’. |
Create corridors
Corridors parameters info
Description
Creates a continuous surface of cumulative paths that connects a set of points. lcc.py in the command line or lcc_py( ) in R. Also, you can use two extra versions of this function to generate equivalent results. The first is a memory-safe version for big files: lccHeavy_py( ) and lcc_heavy.py. The second one is for parallel computing: lccJoblib_py( ) and lcc_joblib.py. lccjoblib.py and lccJoblib_py will work best if you read and write results to your primary hard drive, usually your C: drive. Your primary hard drive should be SSD (most are) and should have at least 50GB of free space (more if you are processing very large landscapes with many points). You can make a rough estimate of free space needed according to the number of cells in your landscape x the number of points x 64 bit x the compression ratio x conversion factor to GB. For example, a 10 million cell landscape with 5000 points will require ~80GB of temporary storage: ((10000000500064)*0.2)/8e9 = 80.
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
| Source points | inshp | String | File path to the point layer. Spatial point layer (any ORG driver), CSV (X, Y files), or *.xy file | |||
| Surface resistance | intif | String | File path to the input raster. Requires a projected file with square pixels. Not LonLat projection allowed | |||
| Output raster filename | outtif | string | File path of the output raster layer written in GeoTiff format. | |||
| Max. dispersal distance in cost units | maxdist | Numeric | This is the maximum distance to consider when calculating corridors and should correspond to the maximum dispersal distance of the focal species. For example, if the maximum dispersal distance of the focal species is 10 km, set this value to 10000. Values greater than this will be converted to 0 before summing corridors. | |||
| Corridor smoothing factor | smooth | Numeric | The width of the window, in the number of cells, is used to smooth the output corridor surface. If no smoothing is desired, set it to 0. This parameter allows backward compatibility with the original UNICOR functionality, which runs a smoothing window over the least-cost path surface. | |||
| Corridor tolerance in cost units | tolerance | String | This is the distance beyond the least-cost path that an animal might traverse when moving between source points. Larger values result in wider corridors. | |||
| Number of cores | ncores | Numeric | PNumber or cores of your computer to run the analysis | |||
| Projection string | crs | String | Projection information in the case the input raster [2] has no spatial projection. Provide it as EPSG or ESRI string e.g. “ESRI:102028”. Default value is ‘None’. | |||
| First temporary h5 file (not used in R) | NA | String | Not used in R, but required in Python. Created as a temporal file internally in R but required in the Python command line. This file is created to store temporal structures in disk and avoid allocate the information on the RAM. This argument is used only in the R and Python version of lcc_heavy( ) and lcc_joblib( ). | |||
| Second temporary h5 file (not used in R) | NA | String | Not used in R, but required in Python. Created as a temporal file internally in R but required in the Python command line. This file is created to store temporal structures in disk and avoid allocate the information on the RAM. This argument is used only in the R and Python version of lcc_heavy( ) and lcc_joblib( ). | |||
| Max GB ram allowed | maxram | Numeric | Maximum gibabytes to use in your machine. The default value is 6. |
Prioritization
Priorization parameters info
Description
Identify and rank existing corridors, assigning a higher rank to the shorter links that connect the bigger nodes. You can use it by prioritize_core_conn.py in the command line or pri_py( ) in R.
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
| Surface resistance | tif | String | File path to the input raster. Requires a GeoTIFF file with square pixels and cost units as distance units | |||
| Kernels | incrk | String | File path to the input kernel GeoTiff raster file. | |||
| Corridors | inlcc | String | File path to the input corridors GeoTiff raster file. | |||
| Masked output raster | maskedcsname | String | The output raster file path of the resulting nodes, derived from the kernels raster and the quantile ([10] threshold) | |||
| Output point layer | outshppoint | String | The output point layer file path of the resulting corridor centroids in ESRI Shapefile format. | |||
| Output polygon layer | outshppol | String | The output polygon layer file path of the resulting corridors in ESRI Shapefile format. | |||
| Output patch polygon layer | outshppatch | String | The output polygon layer file path of the resulting patches in ESRI Shapefile format. | |||
| Output patch raster layer | outtifpatch | String | The output raster layer file path of the resulting patches in GeoTIFF format. | |||
| Output corridor raster layer | outtif | String | The output raster layer file path of the resulting corridors in GeoTIFF format. | |||
| Threshold quantile | threshold | Decimal | Numeric value between zero and one (0 - 1) to convert continuous kernels into discrete patches. | |||
| Maximum distance | maxdist | Numeric | This is the maximum distance to consider when calculating kernels and should correspond to the maximum dispersal distance of the focal species. Values greater than this will be converted to 0 before summing kernels. For example, if the maximum dispersal distance of the focal species is 10 km, set this value to 10000. This should be the same value used for the parameter [4], Max. dispersal distance in cost units in the least cost path function. |
Priorization parameters info
Description
Compares kernels (crk) or corridors (lcc) baseline layers with other scenarios. You can use them by crk_compare.py and lcc_compare.py in the command line or crk_compare_py( ) and lcc_compare_py( ) in R.
Parameters
| Variable | . _ . | Name | . _ . | Type | . _ . | Description |
|---|---|---|---|---|---|---|
| Baseline raster | intif | String | File path to the input baseline kernel or corridor raster. Requires a GeoTIFF file with square pixels and cost units as distance units | |||
| Layers to compare | intifs | String | String of raster layer paths to compare. Requires to be passed as a comma separated single string as “layer1.tif, layer2.tif,layer3.tif,…”. Accepts relative or full paths. Pass the baseline raster again [1] as the first raster. | |||
| Absolute difference out table | outcsvabs | String | File path of the table to be written that contains the absolute values of the layers. Returns one value for argument [1] plus one of each of the layers passed on the argument [2] | |||
| Relative difference out table | outcsvrel | String | File path of the table to be written that contains the relative values of the layers. Returns one value for each of the layers passed on the argument [2] relative to the argument [1] | |||
| Absolute difference out png | outpngabs | String | File path of the barplot image to be written that contains the absolute values of the layers. Returns one value for argument [1] plus one of each of the layers passed on the argument [2] | |||
| Relative difference out png | outpngrel | String | File path of the barplot image to be written that contains the relative values of the layers. Returns one value for each of the layers passed on the argument [2] relative to the argument [1] | |||
| Out folder path | outfolder | String | Data folder path where the comparison rasters will be saved. Writes as many layers as passed in the argument [2] | |||
| Cutline vectorial layer path | inshp | String | File path to a vectorial layer used to cutline the comparison. Default value is ‘None’ for ignoring this parameter. | |||
| Cutline vectorial layer field | shpfield | String | Attribute or column name of the vectorial layer provided if you want to regionalize the comparison. By providing a valid column name the csv table will have a second dimension of the length of the unique values of the column. Default value is ‘None’. |
Landscape genetics
Comming soon ... stay tuned
Running this DSS locally
Check the latests installation slides!Installing Connecting landscapes cola
Non-expert code users can follow this tutorial
Find on this page the details and instructions for a) installation and b) customization cola installation parameters.
This code contains the quick-and-dirt way to install cola. For the full procedure from scratch check the details in the next session.
## Windows users must have git or github installed.
if(!require(devtools)){install.packages('devtools')}
library(devtools) # Library for installing packages from github
devtools::install_github('connectingLandscapes/cola', dependencies = NA, upgrade = 'never') ## Type "3": None ## Installs cola
## If error: Go to https://github.com/connectingLandscapes/cola >> Green button >>
## Download zip >> D:/path/to/cola-main.zip. Then run the following commands:
# install.packages("D:/path/to/cola-main.zip", repos = NULL, type = "win.binary")
## or
# devtools::install_local('D:/path/to/cola-main.zip')
library(cola) # Load cola
cola::setup_cola() # Setup cola. Run this line until all problems are solved.
# Expect 2 pop up windows for accepting to install Miniconda and cola environment
cola::diagnose_cola() # check installation problems -- also suggests solutions
cola::setup_cola() # Run again until solving all installation issue. Required to be
# finished in order to set up the package properly.
file.edit(file.path(Sys.getenv("HOME"), ".Renviron")) # Edit parameters
.rs.restartR() # Restart RStudio
Sys.getenv(c('COLA_PYTHON_PATH', 'COLA_SCRIPTS_PATH')) # Validate DSS parameters
Sys.getenv(c('COLA_DATA_PATH', 'COLA_SCRIPTS_PATH', 'COLA_DSS_UPL_MB', 'COLA_VIZ_THRES_PIX', 'COLA_VIZ_RES_NCOL', 'COLA_VIZ_RES_NROW', 'COLA_NCORES' ))
## Install the front end. Windows users must have Rtools and git installed.
cola::setup_cola_dss() # Setup the DSS libraries. Takes a while. Run until getting a success message
.rs.restartR() # Restart R
library(cola) # Load Cola
cola::cola_dss() # Launch the DSS
A) Installation
This package integrates R and Python modules.
It’s required to install several components (once). The structure of this software is:
-
R as the base. Use the latest available here
-
Only for windows: Have you Rtools already?
devtools::find_rtools()must be TRUE -
Python as the engine for the main scripts
-
Miniconda (conda) environment as the package containing all Python dependencies
-
R shiny is for the dashboard decision support system.
Some of the different computers might have particular conditions or requirements for installing all these components, so we made a section where you can find known issues an their potential solution. If you found a new one please share it with us so potential new users can see it.
If you have any issues installing and setting up the software, please check the KNOWN-ISSUES PAGE (open in a new tab if launched in R/Rstudio/Shiny) for potential solutions
1. Install cola R package.
Consider use the option 3 (None) for installing new packages at the first try. If an error arises, update all of them (option 1).
if (!require(devtools)){
install.packages('devtools')
}
devtools::install_github('connectingLandscapes/cola') ## option 3: None
The installation log will shown in console (type 3 for fast installation):
Downloading GitHub repo connectingLandscapes/cola@HEAD
These packages have more recent versions available.
It is recommended to update all of them.
Which would you like to update?
1: All
2: CRAN packages only
3: None
... (more text)
-- R CMD build -----------------------------------------------------------------------------------------------------------
v checking for file 'C:\tempR\RtmpM1f5us\remotes11c8f5a7145\connectingLandscapes-cola-5abb74a/DESCRIPTION' (378ms)
- preparing 'cola': (1.8s)
v checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
NB: this package now depends on R (>= 3.5.0)
WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: 'cola/data/crs_df.rda' 'cola/data/perfomance-uper_per.rda' WARNING: Added dependency on R >= 3.5.0 because serialized objects in serialize/load version 3 cannot be read in older versions of R. File(s) containing such objects: 'cola/./showcase/showcase.RData'
- building 'cola_0.1.0.tar.gz'
Installing package into ‘C:/Users/Admin/Documents/R/win-library/4.0’
(as ‘lib’ is unspecified)
* installing *source* package 'cola' ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
No man pages found in package 'cola'
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
*** arch - i386
*** arch - x64
** testing if installed package can be loaded from final location
*** arch - i386
*** arch - x64
** testing if installed package keeps a record of temporary installation path
* DONE (cola)
Here, the cola R package is installed. Now we need to set up A) the conda environment and B) the shiny the dashboard
2. Setting up cola requirements:
This might take several minutes and will show the following message once you get all the steps installed. But during the first time you will have a longer log. See next section.
library(cola)
cola::setup_cola()
A final success installation should print:
+Step 1/5: Installing & checking reticulate R package
`reticulate` installed already!
+Step 2/5 Installing & checking miniconda
miniconda found at C:/Users/Admin/AppData/Local/r-miniconda!
+Step 3/5 Installing & checking conda environment
`cola` conda environment installed in C:\Users\Admin\AppData\Local\r-miniconda\envs\cola/python.exe
`cola` conda environment named correctly!
The python version is Python 3.9.19
+Step 4/5 Installing & checking conda modules
All required conda modules installed!
+Step 5/5 Setting up local variables
=== Ready to connect landscapes! ===
If there’s the first time installing cola you will see the following messages during the different steps:
+Step 1/5: Installing & checking reticulate R package
If reticulate R package doesn’t exists, you need to install it. A prompt asking if you want to install packages that requires compilation will appear. If you say “yes” this might take longer. You can also say “No”, but it might require update the packages at some point, depending in your current.
You might need to restart your R session as well. Say “YES”.
Also, you might be asked to install a reticulate conda environment. Say “YES”.
A correct reticulate R package installation will show:
+Step 1/5: Installing & checking reticulate R package
`reticulate` installed already!
+Step 2/5 Installing & checking miniconda
If miniconda is not installed, you will be asked to accept the installation. Say “yes”
A correct miniconda installation will show:
+Step 2/5 Installing & checking miniconda
miniconda found at C:/Users/Admin/AppData/Local/r-miniconda!
+Step 3/5 Installing & checking conda environment
+Step 4/5 Installing & checking conda modules
This steps creates a conda environment, named cola by default. You will ask to create the environment. Say “yes”
It will try several ways in the case some options doesn’t works in your machine:
1. Install the environment using a YML file. If fails,
2. Creating the environment with the required libraries. If fails,
3. Create the environment, and then installing each library independently
This step will take some minutes since requires download spatial and specialized packages.
A correct installation should shown a message like:
+Step 3/5 Installing & checking conda environment
`cola` conda environment installed in C:\Users\Admin\AppData\Local\r-miniconda\envs\cola/python.exe
`cola` conda environment named correctly!
The python version is Python 3.9.19
+Step 4/5 Installing & checking conda modules
All required conda modules installed!
+Step 5/5 Setting up local variables
During this step R will define the ways to interact with the python version and environment. The installation script will find the path to the scripts and identify how your system should call cola python. At the same time, here we load all the required modules to test if were installed correctly, and run a sample analysis to ensure
If all the test passed, this will be the shown:
+Step 5/5 Setting up local variables
=== Ready to connect landscapes! ===
3. Setting up cola dashboard:
Now let’s install all the native R libraries to deply the dashboard.
cola::setup_cola_dss()
If all libraries were installed, the following
=== All libraries required for COLA's DSS installed ===
4. Load cola and run some functions:
Let’s run one of the functions. Habitat suitability to habitat resistance: s2res
library(cola)
input_tif <- system.file(package = 'cola', 'sampledata/sampleTif.tif')
out_shp <- 'outputPoints.shp'
simulated_points <- points_py(intif = input_tif, outshp = out_shp,
param3 = 0, param4 = 100, param5 = 50)
if(file.exists(out_tif)){
plot(sf::read_sf(simulated_points$file))
}
**5. Uninstall cola **
# Not run
# reticulate::conda_remove('cola')
# remove.packages( "cola" )
. B) Customize cola parameters
There’s some parameters we can customize for cola performance, in each of the following parameters:
- Temporal directory
COLA_DATA_PATH: where a folder will be created for each DSS session, and will be used to save the results. By default we use R temporal foldertempdir(). Keep the last slash or backshlash. - Number of cores
COLA_NCORES: To be used for running the programs. Default is1. - Maximum size of the layer
COLA_DSS_UPL_MB: Size to load in the shiniy dashboard in mega bytes (MB) units. Default is250. - Maximum resolution for the layer representation
COLA_VIZ_THREs_PIX,COLA_VIZ_RES_NCOL,COLA_VIZ_RES_NROW: The original layer created or uploaded will be resampled in the front end leaflet visor. This value is the upper threshold fo pixel numbers in the layer. Layers with number of pixels above this number will be resampled toc(1000, 1000)pixels. The default value is1000000for the threshold, and1000for the resampling size in columns and rows. Increase this number to allow your machine load bigger original files in the front end. Decrease this number to avoid loading big files in your front end.
How to edit those variables? Don’t edit this variables unless you are an advanced user
Find your R configuration file .Renviron file located in Sys.getenv("R_USER").
Edit with a text editor this file and edit with caution the values. Keep the proper file separator (\ or /), quotes, decimal separators, etc.
Open the file;
file.edit(file.path(Sys.getenv("HOME"), ".Renviron"))
Populate the values as you consider:
COLA_PYTHON_PATH="C:\Users\gonza\AppData\Local\r-miniconda\envs\cola/python.exe"
COLA_SCRIPTS_PATH="C:/Users/gonza/AppData/Local/R/win-library/4.2/cola/python"
COLA_DATA_PATH="C:/temp/cola"
COLA_NCORES=1
COLA_DSS_UPL_MB=250
COLA_VIZ_THRES_PIX=1000000
COLA_VIZ_RES_NCOL=1000
COLA_VIZ_RES_NROW=1000
You should also see COLA_PYTHON_PATH and COLA_SCRIPTS_PATH, but DON’T edit them manually.
This file is reset to the default values every time you run cola::setup_cola().