Skip to content
Prev 18594 / 29559 Next

Problem with NDVI difference with subset image

Hi Dra. Goslee,

             I work in OS linux and I like very much your lssub 
function, despites your notice. I think that the problems are in linux 
system, because:

 > landc<- stack(c("stackIm1.sample.tif","tackIm2.sample.tif"))
Error in .local(.Object, ...) :
   `/home/asantos/Documentos/Sensoriamento remoto percevejo 
bronzeador/Contornos/tackIm2.sample.tif' does not exist in the file system,
and is not recognised as a supported dataset name.

Error in .rasterObjectFromFile(x, band = band, objecttype = 
"RasterLayer",  :
   Cannot create a RasterLayer object from this file. (file does not exist)


              When I try to look the geotiff created 
(stackIm1.sample.tif) there are something wrong, because the pictures 
doesn't open (complete example below).

Thanks for your attention,

Alexandre

require(raster)
require(sp)
require(rgdal)
require(landsat)
#
#Create raster
r <- raster(nc=1000, nr=1000)
set.seed(20130622)
stackIm1 <- stack(lapply(1, function(x) setValues(r, round(runif(ncell(r))* 255))))## Simulation red band
stackIm2 <- stack(lapply(1, function(x) setValues(r, round(runif(ncell(r))* 255))))## Simulation nir

# define projection system
r.geo <- CRS("+proj=utm +zone=23 +south +datum=WGS84 +units=m +no_defs")    # geographical datum WGS84
proj4string(stackIm1) <- r.geo
proj4string(stackIm2) <- r.geo
#

#Create geotiff
writeRaster(stackIm1, filename="stackIm1.tif", format="GTiff",overwrite=TRUE)
writeRaster(stackIm2, filename="stackIm2.tif", format="GTiff",overwrite=TRUE)
#

#Subset a geotiff image 50 x 50 pixels
stackIm1.sample<-lssub("stackIm1.tif", "stackIm1.sample.tif", centerx = 0, centery = 0, widthx = 50, widthy = 50)
stackIm2.sample<-lssub("stackIm1.tif", "sstackIm2.sample.tif", centerx = 0, centery = 0, widthx = 50, widthy = 50)
#
landc<- stack(c("stackIm1.sample.tif","tackIm2.sample.tif"))





Em 23/06/2013 12:59, Sarah Goslee escreveu: