r-lidar / lidR

Airborne LiDAR data manipulation and visualisation for forestry application
https://CRAN.R-project.org/package=lidR
GNU General Public License v3.0
596 stars 131 forks source link

error with lastrees #108

Closed ErvanCH closed 6 years ago

ErvanCH commented 6 years ago

Dear Jean-Romain, First of all thanks for this impressive package. Super efficient and clean! Love it. I am using some of its functions to delineate tree crowns in Switzerland, mainly on deciduous species (Quercus). As crown are wider than Douglas fire, finding treetops is more challenging. I got my way through this, but once I want to delineate the crown perimeter I got the following error message:

lastrees(las, "watershed", chm, th = 4,extra=T) # segmentation

Error: 'EBImage' package is needed for this function to work. Please read documentation.

install.packages('EBImage' )

Installing package into ‘C:/Users/Ervan/Documents/Work/R/R.library’ (as ‘lib’ is unspecified) Warning in install.packages : package ‘EBImage’ is not available (for R version 3.4.1)

Do I need to downgrade R, or am I doing anything wrong?? Merci pour votre retour et tout le temps passé! Amitiés, Ervan

Jean-Romain commented 6 years ago

Hi Ervan,

This question is not related to the lidR package but to the EBImage package. About the watershed method the lidR documentation says:

This method is a simple watershed segmentation method. It is based on the bioconductor package EBIimage. You need to install this package to run this method (see its github page).

And the EBImage page explains how to install this package:

source("https://bioconductor.org/biocLite.R")
biocLite("EBImage")

Indeed this not a regular CRAN package but a bioconductor package. Thus install.package tell you that EBImage does not exist.

ErvanCH commented 6 years ago

Hi Romain, Thanks for pointing towards the package repository. Now that everything is installed, I got the following error message: trees <- lastrees(las, "watershed", chm, th = 5,extra=F) # segmentation Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘extent’ for signature ‘"lasmetrics"’

Any hint? Thanks E

Jean-Romain commented 6 years ago

I guess I missed something in the code. Try:

trees <- lastrees(las, "watershed", as.raster(chm), th = 5,extra=F)

Edit: actually I didn't missed anything. This is documented :wink: .

ErvanCH commented 6 years ago

Sorry, I missed that line. My fault.

ErvanCH commented 6 years ago

Ah! I noticed a typo here: crown = lastrees(lasnorm, "watershed", chm, th = 4, extra = TRUE) library(raster) contour = rasterToPolygons(crowns, dissolve = TRUE) ## should be "crown" not "crowns" ;)

Jean-Romain commented 6 years ago

where ?

ErvanCH commented 6 years ago

https://github.com/Jean-Romain/lidR/wiki/Tree-segmentation-from-A-to-Z The "Optionally" section

Jean-Romain commented 6 years ago

Ok thank for reporting. There are probably many errors in the wiki pages. I cannot keep everything up-to-date alone (package + doc + wiki) :disappointed: . Do not hesitate to modify the wiki yourself without my permission if you find an error, typo or anything else :wink: