Skip to content
Prev 15737 / 29559 Next

testing for a valid raster format before reading

On Fri, Jul 27, 2012 at 10:08 AM, Mauricio Zambrano-Bigiarini
<mauricio.zambrano at jrc.ec.europa.eu> wrote:
You can use 'try' to run code and catch errors. See help(try) for more:

for(f in files){
 r = try(raster(f))
 if(inherits(r, "try-error")){
      warning("couldnt read ",f)
   }else{
      print(summary(r))
  }
 }