0

I was trying to convert the raster to vector/matrix using getValues and I am getting this error:

Error in (function (classes, fdef, mtable)  : unable to find an inherited method for function ‘getValues’ for signature ‘"character", "missing", "missing"

I have put the code below for reference.

#mosaic

Mosaic<- "Mosaic.tif"

#shapefile

shp <- "Tahsil Boundary2001.shp"

#Extacted Raster

gondia<- "extract.tif"

#convert raster to vector\matrix

nr <- getValues(gondia)

1 Answer 1

0

I suppose that you want to use getValues from raster package. You have to create raster object with raster() function. In your case you just store string "extract.tif" into variable gondia so:

gondia <- "extract.tif"
gondia

results in

[1] "extract.tif"

Just try:

gondia <- raster("extract.tif")
nr <- getValues(gondia)

For further details see getValues documentation.

2
  • 1
    Thanks a lot, I tried as you suggested and it worked. I will go through for more information.
    – Manish1013
    Commented Jan 31, 2021 at 16:57
  • Perfect, please if the answer solved your question, mark it as "accepted", which indicates that this thread is resolved. Also see quick starting tour at gis.stackexchange.com/tour
    – Oto Kaláb
    Commented Jan 31, 2021 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.