Failure during raster IO

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Failure during raster IO

klborgmann
I am new to Raster and posting in stackoverflow. When I attempt to plot
stacked rasters or use the predict function I get an error: failure during
raster IO. I have googled the error message but have not found any useful
suggestions as to what could be causing the error. All of my packages are
up-to-date, the layer names and the model names are the same, so that
should not be causing a problem. Perhaps there is something wrong with the
raster files? My raster is composed of 150x150 cells with an associated
attribute table that contains x/y and values for one attribute (eg., em or
p1). I am very new to working with rasters so please excuse my naivete. Any
thoughts or suggestions are greatly appreciated!!

Here's my model

m2<-glm(occu~p1+em, data=clra, family="binomial")

and my rasters

p1<-raster("P1.txt", RAT=TRUE) #read rasters
em<-raster("EM.txt", RAT=TRUE)
ext<-extent(-1892138, -1378238, 1115643, 1653543) #set extents equal
p1<-setExtent(p1,ext, keepres=TRUE, snap=TRUE)
em<-setExtent(em,ext, keepres=TRUE, snap=TRUE)
attributes<-stack(p1,em)

plot(attributes)
Error:failure during raster IO
predict<-stack(p1,em)
Error:failure during raster IO

Thanks

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

Robert Hijmans
Kathi,

What you are doing does not look right, but you should get a clearer
message about that. As is, I believe this is a bug.
I think the problem is here:

p1<-setExtent(p1,ext, keepres=TRUE, snap=TRUE)
em<-setExtent(em,ext, keepres=TRUE, snap=TRUE)

You are changing the extent while keeping the resolution the same. This
probably creates phantom rows and columns. You normally should not change
the extent. But if you do, you could try

extent(p1) <- extent(em)

Robert

On Wed, Jan 30, 2013 at 8:17 AM, Kathi Borgmann <[hidden email]>wrote:

> I am new to Raster and posting in stackoverflow. When I attempt to plot
> stacked rasters or use the predict function I get an error: failure during
> raster IO. I have googled the error message but have not found any useful
> suggestions as to what could be causing the error. All of my packages are
> up-to-date, the layer names and the model names are the same, so that
> should not be causing a problem. Perhaps there is something wrong with the
> raster files? My raster is composed of 150x150 cells with an associated
> attribute table that contains x/y and values for one attribute (eg., em or
> p1). I am very new to working with rasters so please excuse my naivete. Any
> thoughts or suggestions are greatly appreciated!!
>
> Here's my model
>
> m2<-glm(occu~p1+em, data=clra, family="binomial")
>
> and my rasters
>
> p1<-raster("P1.txt", RAT=TRUE) #read rasters
> em<-raster("EM.txt", RAT=TRUE)
> ext<-extent(-1892138, -1378238, 1115643, 1653543) #set extents equal
> p1<-setExtent(p1,ext, keepres=TRUE, snap=TRUE)
> em<-setExtent(em,ext, keepres=TRUE, snap=TRUE)
> attributes<-stack(p1,em)
>
> plot(attributes)
> Error:failure during raster IO
> predict<-stack(p1,em)
> Error:failure during raster IO
>
> Thanks
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

klborgmann
Thanks Robert!
That did eliminate the Failure during raster IO
I am following your example vignette for SDM (page 31) and have several raster layers with wetland attributes that have different extents.  It seems that in order to stack rasters they have to be the same extent, hence why I was trying to change the extents of the rasters.  Is there a better method for combining rasters with different extents to allow for spatial predictions based on a glm model? My model has three wetland attributes and I have a raster layer for each wetland attribute.
Thanks Again!!
-Kathi
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

Robert Hijmans
Kathi,
It would probably be useful to read vignette('raster') and to look at the
'crop' function (and  'extend', 'resample', and 'aggregate').
Robert

On Thu, Jan 31, 2013 at 2:41 PM, klborgmann <[hidden email]> wrote:

> Thanks Robert!
> That did eliminate the Failure during raster IO
> I am following your example vignette for SDM (page 31) and have several
> raster layers with wetland attributes that have different extents.  It
> seems
> that in order to stack rasters they have to be the same extent, hence why I
> was trying to change the extents of the rasters.  Is there a better method
> for combining rasters with different extents to allow for spatial
> predictions based on a glm model? My model has three wetland attributes and
> I have a raster layer for each wetland attribute.
> Thanks Again!!
> -Kathi
>
>
>
> --
> View this message in context:
> http://r-sig-geo.2731867.n2.nabble.com/Failure-during-raster-IO-tp7582421p7582447.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> [hidden email]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

ideltoro
Hello Robert and Kathi,
I am getting the same "Failure during raster IO" error when I use the extract function in the raster package.
Any ideas why this might be happening. I am also using Robert's SDM guide and trying to build a GLM.

train <-      rbind(pres_train, backg_train)                                          
pb_train <-   c(rep(1, nrow(pres_train)), rep(0, nrow(backg_train)))                  
envtrain <-   extract(predictors, train)                    

where "predictors" is my raster stack of BioClim variables and "train" is the set of coordinates for the training and background points.

Any thoughts on why thing might be happening at this stage?

Cheers!                            
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

klborgmann
This post has NOT been accepted by the mailing list yet.
Hello,
My problem was associated with using a computer that could not handle my large dataset.  Once I switched to a more powerful computer everything worked fine. sorry I cannot be of more help


On Mon, Jun 24, 2013 at 5:03 PM, ideltoro [via R-sig-geo] <[hidden email]> wrote:
Hello Robert and Kathi,
I am getting the same "Failure during raster IO" error when I use the extract function in the raster package.
Any ideas why this might be happening. I am also using Robert's SDM guide and trying to build a GLM.

train <-      rbind(pres_train, backg_train)                                          
pb_train <-   c(rep(1, nrow(pres_train)), rep(0, nrow(backg_train)))                  
envtrain <-   extract(predictors, train)                    

where "predictors" is my raster stack of BioClim variables and "train" is the set of coordinates for the training and background points.

Any thoughts on why thing might be happening at this stage?

Cheers!                            


If you reply to this email, your message will be added to the discussion below:
http://r-sig-geo.2731867.n2.nabble.com/Failure-during-raster-IO-tp7582421p7583906.html
To unsubscribe from Failure during raster IO, click here.
NAML



--
- Kathi 
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

Ariel Ortiz-Bobea
In reply to this post by ideltoro
Ran into a similar problem and was getting "Failure during raster IO" when using extract on a very large raster with a small polygon. My solution was to crop the large raster before doing the extract. Maybe this can help other folks in the future. Cheers.
Ariel
Ariel Ortiz-Bobea
Assistant Profesor in Applied Economics and Management
Cornell University
Adi
Reply | Threaded
Open this post in threaded view
|

Re: Failure during raster IO

Adi
In reply to this post by ideltoro
I just got "Failure during raster IO" error when I used the extract function in the raster package.
I was working with a big raster stack (43 rasters).
The cause was that one of these rasters was corrupted on the disk.
It would be useful to check with a GIS viewer each raster individually.