Would it be possible at cmake-build/package level to generate these kind of code for R ?
If this can get to talk with allies already on R (grass, gdal etc…) that is cool.
I didn’t looked any detail in to R code. I put this thread to see if there is any interest or idea on R and OTB. This particular answer “looks” nice, so just moved this to forum.
Feel free to send your thoughts.
Using R as a geospatial scripting language is very convenient, particularly for the many (> 6 M) R users that are reluctant to learn python also… OTB is much faster than R as soon as you get moderately sized images, but usning R as the “glue” is very convenient.
I often run OTB from within R using a very similar approach, I run otbenv.profile before the actual otbcli command to ensure portability. The fact that otbcli* commands are named otbcli*.bat on windoze
makes you check the OS.
It is not strictly needed to write an R function such as aldo_tapia did (although it is very convenient if you plan to use it more than once), i.e.
#5 Calculate Reflectance using OTB (gdal_calc.py produces weird results)
print(“Calculating and saving Reflectance image…”)
comm1 <- file.path(otbpath,“otbcli_BandMathX -progress 0 -il”)
comm2 <- paste(file.path(imadir,fnameimaRad),
comm3 <- “-out result.tif -exp ‘(im1-im2) div (im3-im2)’”
comm <- paste(comm1, comm2, comm3)
cat(". /home/alobo/OTB-6.6.1-Linux64/otbenv.profile \n",comm,file=“test.scr”)
system(“sh test.scr”, intern=TRUE)
“-out result.tif -exp “(im1-im2) div (im3-im2)””,
but generalizing this into a otbcli_BandMathX.R function would be better.
It would be good if everyone working with R/OTB could share simple functions such as the one by aldo_tapia, we could make a collaborative ROTB package. The goal would be having an R function for running each otbcli command. We would need to agree on some common style.
according to your interest I have updated a straightforward wrapper for OTB functions which is provided by the R package
link2GI . It is designed for an easy use of all versions of OTB without never ending copy and past tasks. You find more information at:
Usage of Orfeo Toolbox from R.
The package is on cran. You will find the most recent version on github link2GI
Excellent Chris, many thanks.
Your package makes things easier for running OTB processes from
within R scripts.
I’ll keep on contributing issue reports and suggestions to your github site
and will report here on experiences.
You’re welcome and thank you back Agus. Your contributions and suggestions are very beneficial. I am glad to be able to count on your support in the future as well.