1

I have two files, where the NDVI is at 250m and the LST is at 1k, I want to use resample of R to convert the LST to 250m.

ndvi <- raster("MOD13Q1.A2014017.tif")   
lst <- raster("MOD11A2.A2014017.tif")  
LST250 <- resample(lst, ndvi, method="ngb", filename="lst_250.tif")

But I get the following error, they could help me

enter image description here

[Edit] Unfortunately, I have discovered that it is not possible to do a function with resample, apparently it can only be called once, otherwise it gives me the error I have shown

resample <- function(){  
    ndvi <- raster("MOD13Q1.A2014017.tif")  
    lst <- raster("MOD11A2.A2014017.tif")  
    LST250 <- resample(lst, ndvi, method="ngb", filename="lst_250.tif")  
}

resample()
  • Maybe you have opened another package with a function with the same name. Try with raster::resample(...) – aldo_tapia Nov 13 '16 at 17:25
  • @aldo_tapia yeah, I agree. A simple test works for me, and there's a lot of other packages that create resample: rdocumentation.org/search?q=resample – Spacedman Nov 13 '16 at 17:43
  • What you've done is written a function called resample that calls resample - which then find your resample function instead of the one in the raster package. So since your resample function has no arguments then it gives an error because your call in the function has some arguments. If you really want to call your function resample then you need to call the raster package function as raster::resample(...etc...). – Spacedman Nov 14 '16 at 15:47
  • Yes, off course. Three points represents yours arguments, the aim of my comment was indicate how to call resample() to avoid confusion with others functions. Also, be careful with writeRaster() (same name in raster and rasclass package). If resample() doesn't work (as you say), use projectRaster(). – aldo_tapia Nov 16 '16 at 2:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.