Jean-Romain / lidRplugins

Extra functions and algorithms for lidR package
42 stars 15 forks source link

re-implement the lmfx algorithm using lidR v3.0.0 framework #7

Closed mikoontz closed 4 years ago

mikoontz commented 4 years ago

From this discussion: https://github.com/Jean-Romain/lidRplugins/issues/5

I re-implemented the lmfx algorithm and have swapped in the appropriate lidR v3.0.0 changes. I built my forked version with roxygen2 to get the man/ and the NAMESPACE files written properly.

I've been able to install this version from my fork (remotes::install_github("mikoontz/lidRplugins@master")) and it works as expected when using the lidR devel branch (remotes::install_github("Jean-Romain/lidR@devel"))

mikoontz commented 4 years ago

And my apologies for some of those commits being erroneous!

Jean-Romain commented 4 years ago

I'll have a look before to merge to ensure everything is ok.

mikoontz commented 4 years ago

sounds good, thanks!

mikoontz commented 4 years ago

I haven't checked with R CMD check but can do that. I'm currently having trouble installing lidR@devel on macOS Catalina, so might have to do this testing on my Windows machine.

Edit: And I can also make the above changes.

mikoontz commented 4 years ago

I'm using {devtools} and RStudio to run R CMD check and am getting errors, but not in lmfx. Here's the log:

==> Rcpp::compileAttributes()

* Updated src/RcppExports.cpp
* Updated R/RcppExports.R

==> devtools::check()

Updating lidRplugins documentation
Loading lidRplugins
Re-compiling lidRplugins
─  installing *source* package ‘lidRplugins’ ...
   ** using staged installation
   ** libs
   clang++ -std=gnu++11 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/BH/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/include" -I"/Library/Frameworks/R.framework/Versions/3.6/Resources/library/RcppArmadillo/include" -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/usr/local/include  -fPIC  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -c RcppExports.cpp -o RcppExports.o
   clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -Wl,-rpath,/Library/Frameworks/R.framework/Resources/lib /Library/Frameworks/R.framework/Resources/lib/libc++abi.1.dylib -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o lidRplugins.so BoundingBox.o C_lastree_hamraz.o C_lastrees_Ptrees.o HamrazProfiles.o Progress.o QuadTree.o RcppExports.o Shapes.o TreeSegment.o TreeSegmentManager.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
   ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
   installing to /private/var/folders/xl/hy7rwmvx4llff5_00gwbk2vh0000gp/T/RtmpOkJfy5/devtools_install_8a361ee7f5f3/00LOCK-lidRplugins/00new/lidRplugins/libs
   ** checking absolute paths in shared objects and dynamic libraries
─  DONE (lidRplugins)
Loading required package: lidR
Loading required package: raster
Loading required package: sp
Writing NAMESPACE
Writing NAMESPACE
── Building ────────────────────────────────────────────────────────────────────────────── lidRplugins ──
Setting env vars:
● CFLAGS    : -Wall -pedantic -fdiagnostics-color=always
● CXXFLAGS  : -Wall -pedantic -fdiagnostics-color=always
● CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always
─────────────────────────────────────────────────────────────────────────────────────────────────────────
✓  checking for file ‘/Users/michaelkoontz/dev/lidRplugins/DESCRIPTION’ ...
─  preparing ‘lidRplugins’:
✓  checking DESCRIPTION meta-information ...
─  cleaning src
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
─  building ‘lidRplugins_0.2.0.tar.gz’

── Checking ────────────────────────────────────────────────────────────────────────────── lidRplugins ──
Setting env vars:
● _R_CHECK_CRAN_INCOMING_REMOTE_: FALSE
● _R_CHECK_CRAN_INCOMING_       : FALSE
● _R_CHECK_FORCE_SUGGESTS_      : FALSE
● NOT_CRAN                      : true
── R CMD check ─────────────────────────────────────────────────────────────────
─  using log directory ‘/Users/michaelkoontz/dev/lidRplugins.Rcheck’
─  using R version 3.6.3 (2020-02-29)
─  using platform: x86_64-apple-darwin15.6.0 (64-bit)
─  using session charset: UTF-8
─  using options ‘--no-manual --as-cran’ (382ms)
✓  checking for file ‘lidRplugins/DESCRIPTION’
─  checking extension type ... Package
─  this is package ‘lidRplugins’ version ‘0.2.0’
─  package encoding: UTF-8
✓  checking package namespace information
✓  checking package dependencies (11s)
✓  checking if this is a source package
✓  checking if there is a namespace
✓  checking for executable files (364ms)
✓  checking for hidden files and directories
✓  checking for portable file names ...
✓  checking for sufficient/correct file permissions
✓  checking serialization versions ...
✓  checking whether package ‘lidRplugins’ can be installed (41.2s)
N  checking installed package size ...
     installed size is 15.1Mb
     sub-directories of 1Mb or more:
       extdata  13.8Mb
       libs      1.1Mb
✓  checking package directory ...
✓  checking for future file timestamps (777ms)
✓  checking DESCRIPTION meta-information ...
✓  checking top-level files
✓  checking for left-over files
✓  checking index information
✓  checking package subdirectories ...
✓  checking R files for non-ASCII characters ...
✓  checking R files for syntax errors ...
✓  checking whether the package can be loaded (1.2s)
✓  checking whether the package can be loaded with stated dependencies (1.2s)
✓  checking whether the package can be unloaded cleanly (1.2s)
✓  checking whether the namespace can be loaded with stated dependencies (1.2s)
✓  checking whether the namespace can be unloaded cleanly (1.2s)
✓  checking loading without being on the library search path (1.3s)
W  checking dependencies in R code (3.1s)
   '::' or ':::' imports not declared from:
     ‘RcppConcaveman’ ‘velox’
   'loadNamespace' or 'requireNamespace' call not declared from: ‘velox’
   Missing object imported by a ':::' call: ‘lidR:::opt_copy’
✓  checking S3 generic/method consistency (2s)
✓  checking replacement functions (1.2s)
✓  checking foreign function calls (1.4s)
✓  checking R code for possible problems (6.9s)
✓  checking Rd files ...
✓  checking Rd metadata ...
✓  checking Rd line widths ...
✓  checking Rd cross-references ...
✓  checking for missing documentation entries (1.2s)
✓  checking for code/documentation mismatches (3.4s)
W  checking Rd \usage sections ...
   Undocumented arguments in documentation object 'catalog_boundary'
     ‘simplify’

   Functions with \usage entries need to have the appropriate \alias
   entries, and all their arguments documented.
   The \usage entries must correspond to syntactically valid R code.
   See chapter ‘Writing R documentation files’ in the ‘Writing R
   Extensions’ manual.
✓  checking Rd contents (2s)
✓  checking for unstated dependencies in examples ...
✓  checking line endings in C/C++/Fortran sources/headers ...
✓  checking line endings in Makefiles
✓  checking compilation flags in Makevars ...
✓  checking for GNU extensions in Makefiles
✓  checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS)
✓  checking use of SHLIB_OPENMP_*FLAGS in Makefiles ...
✓  checking pragmas in C/C++ headers and code ...
✓  checking compilation flags used
✓  checking compiled code ...
─  checking examples ...sh: line 1: 36369 Abort trap: 6           LANGUAGE=en _R_CHECK_INTERNALS2_=1 R_LIBS=/var/folders/xl/hy7rwmvx4llff5_00gwbk2vh0000gp/T//RtmpS0YhBJ/RLIBS_8b90393374b1 R_ENVIRON_USER='' R_LIBS_USER='' R_LIBS_SITE='no_such_dir' '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla --encoding=UTF-8 > 'lidRplugins-Ex.Rout' 2>&1 < lidRplugins-Ex.R (2.6s)
    ERROR
   Running examples in ‘lidRplugins-Ex.R’ failed
   The error most likely occurred in:

   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
   > ### Name: catalog_boundary
   > ### Title: Computes the polygons that encloses the points
   > ### Aliases: catalog_boundary
   > 
   > ### ** Examples
   > 
   > LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
   > ctg <- readLAScatalog(LASfile, filter = "-drop_z_below 2")
   > ctg2 <- catalog_boundary(ctg, 2, 2)
   Assertion failed: (0), function query, file ../../../../src/geos-3.7.2/src/index/strtree/AbstractSTRtree.cpp, line 293.
   ** found \donttest examples: check also with --run-donttest
✓  checking for unstated dependencies in ‘tests’ ...
─  checking tests ...
E  Running ‘testthat.R’ [30s/20s] (19.9s)
   Running the tests in ‘tests/testthat.R’ failed.
   Last 13 lines of output:
     1/2 mismatches
     [1] 230 - 233 == -3

     ── 2. Failure: tree_detection ptree works with a LAScatalog (@test-tree_detection.R#47)  ────────────────
     dim(ttops@data) not equal to c(231, 2).
     1/2 mismatches
     [1] 232 - 231 == 1

     ══ testthat results  ════════════════════════════════════════════════════════════════════════════════════
     [ OK: 11 | SKIPPED: 0 | WARNINGS: 1 | FAILED: 2 ]
     1. Failure: tree_detection ptree works with a LAS (@test-tree_detection.R#39) 
     2. Failure: tree_detection ptree works with a LAScatalog (@test-tree_detection.R#47) 

     Error: testthat unit tests failed
     Execution halted
✓  checking for detritus in the temp directory

   See
     ‘/Users/michaelkoontz/dev/lidRplugins.Rcheck/00check.log’
   for details.

── R CMD check results ────────────────────────────────── lidRplugins 0.2.0 ────
Duration: 1m 46.8s

> checking examples ...sh: line 1: 36369 Abort trap: 6           LANGUAGE=en _R_CHECK_INTERNALS2_=1 R_LIBS=/var/folders/xl/hy7rwmvx4llff5_00gwbk2vh0000gp/T//RtmpS0YhBJ/RLIBS_8b90393374b1 R_ENVIRON_USER='' R_LIBS_USER='' R_LIBS_SITE='no_such_dir' '/Library/Frameworks/R.framework/Resources/bin/R' --vanilla --encoding=UTF-8 > 'lidRplugins-Ex.Rout' 2>&1 < lidRplugins-Ex.R
   ERROR
  Running examples in ‘lidRplugins-Ex.R’ failed
  The error most likely occurred in:

  > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
  > ### Name: catalog_boundary
  > ### Title: Computes the polygons that encloses the points
  > ### Aliases: catalog_boundary
  > 
  > ### ** Examples
  > 
  > LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
  > ctg <- readLAScatalog(LASfile, filter = "-drop_z_below 2")
  > ctg2 <- catalog_boundary(ctg, 2, 2)
  Assertion failed: (0), function query, file ../../../../src/geos-3.7.2/src/index/strtree/AbstractSTRtree.cpp, line 293.

> checking tests ...
  See below...

> checking dependencies in R code ... WARNING
  '::' or ':::' imports not declared from:
    ‘RcppConcaveman’ ‘velox’
  'loadNamespace' or 'requireNamespace' call not declared from: ‘velox’
  Missing object imported by a ':::' call: ‘lidR:::opt_copy’

> checking Rd \usage sections ... WARNING
  Undocumented arguments in documentation object 'catalog_boundary'
    ‘simplify’

  Functions with \usage entries need to have the appropriate \alias
  entries, and all their arguments documented.
  The \usage entries must correspond to syntactically valid R code.
  See chapter ‘Writing R documentation files’ in the ‘Writing R
  Extensions’ manual.

> checking installed package size ... NOTE
    installed size is 15.1Mb
    sub-directories of 1Mb or more:
      extdata  13.8Mb
      libs      1.1Mb

── Test failures ───────────────────────────────────────────────── testthat ────

> library(testthat)
> library(lidRplugins)
Loading required package: lidR
Loading required package: raster
Loading required package: sp
> 
> test_check("lidRplugins")
── 1. Failure: tree_detection ptree works with a LAS (@test-tree_detection.R#39)  ───────────────────────
dim(ttops@data) not equal to c(233, 2).
1/2 mismatches
[1] 230 - 233 == -3

── 2. Failure: tree_detection ptree works with a LAScatalog (@test-tree_detection.R#47)  ────────────────
dim(ttops@data) not equal to c(231, 2).
1/2 mismatches
[1] 232 - 231 == 1

══ testthat results  ════════════════════════════════════════════════════════════════════════════════════
[ OK: 11 | SKIPPED: 0 | WARNINGS: 1 | FAILED: 2 ]
1. Failure: tree_detection ptree works with a LAS (@test-tree_detection.R#39) 
2. Failure: tree_detection ptree works with a LAScatalog (@test-tree_detection.R#47) 

Error: testthat unit tests failed
Execution halted

2 errors x | 2 warnings x | 1 note x
Error: R CMD check found ERRORs
Execution halted

Exited with status 1.
Jean-Romain commented 4 years ago

I'll check the mentioned errors

mikoontz commented 4 years ago

Sounds great! I'll note that I've also been successfully using the ptree algorithm in addition to the lmfx algorithm using this patched version of {lidRplugins}, despite the error suggesting that ptree might not work with a LAS file.