pkgdown/custom.css

Skip to contents pkgdown/home.html

Why the installation process is more complex

The installation of canObsR involves several steps that go beyond a typical R package. This is because the package acts as a bridge between different tools used for processing imagery.

Python integration: Some key processing steps rely on specialized Python libraries. To make this work seamlessly from R, we use the reticulate package, which requires setting up a Python environment via Miniconda. This allows us to run Python scripts directly from R functions.

Environment setup: We provide a .yml file to create a dedicated Python environment with all the required dependencies. This ensures that the Python code used in the package runs reliably, regardless of the user’s system.

Metashape integration: Some image processing steps rely on Agisoft Metashape, a commercial software. To use these features, Metashape must be installed, and a valid license key must be activated.

Although the setup may seem complex at first, it ensures that once installed, all components work together smoothly.

📥 Install R, Rtools et RStudio

🔹 R : Download and install the last version of R on the CRAN R

🔹 Rtools : Download and install CRAN Rtools

🔹 RStudio : Download and install RStudio Desktop


📦 Install canObsR

In RStudio console

install.packages("devtools")
library(devtools)
install_github("https://github.com/umr-amap/canObsR.git")

⚙️ Install Miniconda

In RStudio console

library(reticulate)
reticulate::install_miniconda()
library(reticulate)
use_condaenv("r-reticulate", required = TRUE)

🏗 Create and configurate the conda environment

In RStudio console

library(canObsR)

YAML_file <- system.file("PYTHON/environment.yaml", package = "canObsR")
envname <- "canObsR-env"
conda_exe <- detect_conda(auto_select = FALSE)

system2(conda_exe, args = c("env", "create", "-n", envname, "--file", shQuote(YAML_file)))

🏗 Install de Metashape

The environment you just created contains already all necessary dependences but the Metashape python API, which is required to align photos using TimeSIFT.

🔻 Download the .whl file here : https://www.agisoft.com/downloads/installer/

Go to the “Python 3 module” section and click on the link corresponding to your operating system. This should download a file named “Metashape[…].whl”. Then, copy the path to the downloaded .whl file below

In RStudio console

whl_file <- ".../Metashape-2.2.1-cp37.cp38.cp39.cp310.cp311-none-win_amd64.whl"

use_condaenv(envname, required = TRUE)
if (file.exists(whl_file)) {
  message("Installation of Metashape from the .whl file…")
  py_install(
    packages = whl_file,
    pip = TRUE
  )
} else {
  warning("❌️ File .whl not found : ", whl_file)
}

py_module_available("Metashape") # Should be TRUE

🔑 Metashape license activation

Your python environment should be ready for use now. However, Agisoft Metashape requires a paid license in order to access all its features. It is not necessary to have the Metashape application installed on your device in order for the python API to work, but whether or not the application is installed and/or activated, the API still needs to be activated using a license key (it can be the same used for the application if it is already installed).

In RStudio console

install.packages("reticulate")
reticulate::py_run_string("
import Metashape
# Replace 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX' with your key
license_key = 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'
if Metashape.license().activate(license_key):
    print('✅ Metashape Licence activated with success.')
else:
    print('❌ Metashape License not activated.')
")

Or you can also do it using the Anaconda command prompt

To activate the key, follow these steps :

  • Open an anaconda command prompt
  • Activate the environnement you just created, and start python :
conda activate canObs_env
python

Now you can activate the licence (replace with your license key):

import Metashape
Metashape.license.activate("AAAA-BBBB-CCCC-DDDD")

If that works, you can close the command prompt. You should be good to go ! 🎉


🔁 Restart R

In RStudio console

library(reticulate)
library(canObsR)

envname <- "canObsR-env"
use_condaenv(envname, required = TRUE)
pkgdown/footer.html