I'm trying to extract pixel value using the extract()
function from raster
package in R and get the following error, bellow in my code bellow a well, where: df$PixelNumber
is the "cell number value". The error :
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘extract’ for signature ‘"character", "numeric"’
the code I'm using:
vec=as.vector(as.numeric(as.matrix(df$PixelNumber)));
rast = file.choose();
VlaueSlope=extract(x= rast, vec)
What could I be doing wrong in the extract()
code that cannot get the pixel value in the variable VlaueSlope
.
vec = as.numeric(as.matrix(df$PixelNumber)))
?