Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with winFun in TreeTopFinder #4

Closed
QuirinH opened this issue Feb 5, 2018 · 8 comments
Closed

Problem with winFun in TreeTopFinder #4

QuirinH opened this issue Feb 5, 2018 · 8 comments

Comments

@QuirinH
Copy link

QuirinH commented Feb 5, 2018

Hi,

I am having trouble with the TreeTopFinder in ForestTools. The winFun function seems to result in oversized window sizes that give me back an error.

My code:

library(ForestTools)
library(raster)
raster <- raster("~/Desktop/FileName.tif")
lin <- function(x){x * 0.05 + 0.6}

The data has the following specs:

raster
class : RasterLayer
dimensions : 167, 248, 41416 (nrow, ncol, ncell)
resolution : 2.995115e-05, 2.991972e-05 (x, y)
extent : -123.4957, -123.4882, 48.94425, 48.94925 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
data source : /Users/name/Desktop/FileName.tif
names : FileName
values : 0.002187729, 33.21095 (min, max)

ttops <- TreeTopFinder(CHM = raster, winFun = lin, minHeight = 5, verbose = TRUE)

ttops <- TreeTopFinder(CHM = raster, winFun = lin, minHeight = 5, verbose = TRUE)
Reading input raster
Error in TreeTopFinder(CHM = raster, winFun = lin, :
Input function for 'winFun' yields a window size of 200001, which is wider than 'maxWinDiameter'.
Change input function or set 'maxWinDiameter' to a higher value (or to NULL).

I am not sure why the calculated values for window size a re so big. My max value in the data is 33.2. Thank you for your support!

Cheers,
Quirin

@andrew-plowright
Copy link
Owner

Hi Quirin,

The function uses the resolution of the raster to figure out how many cells the window needs to cover. Since it can't know what unit the raster values are in, it assumes that they are the same as the map unit. The problem here is that your raster values are presumably in meters while your resolution is in degrees decimal.

Andrew

@QuirinH
Copy link
Author

QuirinH commented Feb 5, 2018 via email

@andrew-plowright
Copy link
Owner

No problem Quirin, Good luck with your analysis

@Tehn01
Copy link

Tehn01 commented Nov 26, 2020

Hi Andrew and Quiring

I am Having this error;Error in vwf(CHM = fri_chm, winFun = lin, minHeight = 2) :
Input function for 'winFun' yields a window diameter of 119 cells, which is wider than the maximum allowable value in 'maxWinDiameter'.
Change the 'winFun' function or set 'maxWinDiameter' to a higher value (or to NULL)

I think it is the same issue raised, but I am still a beginner and I am not sure how to rectify this.

This is the code;
library(ForestTools)
library(raster)
library(rgdal)
fri_chm <- raster("G:/MSc Thesis/UAV DATA/Resampling/chm/fri_chm.tif")
plot(fri_chm, xlab = "", ylab = "", xaxt='n', yaxt = 'n')
lin <- function(x){x * 0.05 + 0.6}
ttops <- vwf(CHM = fri_chm, winFun = lin, minHeight = 2)

Please help!

@QuirinH
Copy link
Author

QuirinH commented Nov 26, 2020

Hi Tehn01,

I am citing Andrew from above: "The problem here is that your raster values are presumably in meters while your resolution is in degrees decimal." IT was a simple mistake on my end.

For my data it helped to change the dimension to degrees decimal if I remember correctly. I can did up my analysis if that doesn't help.

Good Luck!

@andrew-plowright
Copy link
Owner

Hi @Tehn01,

What @QuirinH said is indeed a common issue. Let's confirm: can you tell us what projection system your CHM is in?

Andrew

@Tehn01
Copy link

Tehn01 commented Dec 7, 2020

Hi @QuirinH @andrew-plowright

Thank you for the feedback, and yes you were right. it was a projection issue. I however have a new inquiry today.

I managed to run the treetop detection and crowns segmentation, however the results are not convincing since most treetops and crowns are not tagged. Is there a way I can improve on the linear function of play around window size for better results?

Cheers!

@andrew-plowright
Copy link
Owner

@Tehn01 yes, the window size is dynamically set by the winFun argument, which takes a function that relates the CHM pixel value to the search window's radius.

The inventors of the algorithm discuss ways to calibrate the window function to specific forest structures:
https://www.ingentaconnect.com/contentone/asprs/pers/2004/00000070/00000005/art00003?crawler=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants