Problem with file in TreeTopFinder (vwf)

Hello,

I am implementing the VWF function to a raster of a canopy height model but when I try to run the code it gives me an error.

My chm file:

class : RasterLayer
dimensions : 3944, 3563, 14052472 (nrow, ncol, ncell)
resolution : 0.0502, 0.052 (x, y)
extent : 758223.1, 758402, 8178203, 8178408 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=21 +south +ellps=GRS80 +units=m +no_defs
data source : in memory
names : área
values : -0.856781, 14.27667 (min, max)

My chm file size is about 53.276 kb:

file.size("/Users/name/Desktop/CHM.tif")
[1] 54553763`

My code:

library(ForestTools)
library(raster)
library(installr)
require(rgdal)
data=raster("área.TIF")
plot(data, xlab = "", ylab = "", xaxt='n', yaxt = 'n')
lin <- function(x){x * 0.05 + 0.6}
wgs84.p4s <- "+proj=utm +zone=21 +south +ellps=GRS80 +units=m +no_defs"
data <- projectRaster(data, crs=wgs84.p4s,method="ngb")
plot(data, axes=T)
data
ttops <- vwf(CHM = data, winFun = lin, minHeight = 0.20)

My error:

Error in vwf(CHM = data, winFun = lin, minHeight = 0.2, maxWinDiameter = NULL) :
Input 'CHM' does not have square cells

Example with data from ForestTools package:

library(ForestTools)
library(raster)
data("kootenayCHM")
par(mar = rep(0.5, 4))
plot(kootenayCHM, xlab = "", ylab = "", xaxt='n', yaxt = 'n')
lin <- function(x){x * 0.05 + 0.6}
ttops <- vwf(CHM = kootenayCHM, winFun = lin, minHeight = 2)
plot(kootenayCHM, xlab = "", ylab = "", xaxt='n', yaxt = 'n')
plot(ttops, col = "blue", pch = 20, cex = 0.5, add = TRUE)

Thanks.
Dhonatan Pessi

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.