The raster is probably too big? -- difficult too know without access to your file. 

A limitation of gdistance is that everything should be done in memory.


You could try to aggregate the grid.

You should remove all NA values from the raster. Running trim() is not enough. 

You can use standard R syntax:

r[is.na(r)] <- 0

Or use the function calc:

r <- calc(r, function(x) ifelse(is.na(x), 0, x) )

Jacob.



________________________________
 From: Ian Craig <icraig@jhsph.edu>
To: r-sig-geo@r-project.org 
Sent: Wednesday, 27 June 2012, 13:05
Subject: [R-sig-Geo] costDistance with gdistance error

Hello geo-savvy R people,

I am new to this list so please be forgiving if I don't include everything
that is needed.  I am having trouble with some code I wrote using the
gdistance package.

#I loaded an ESRI ascii grid file
cost <- read.asciigrid("filepath", as.image = F, plot.image=F,, proj4string
= CRS("+proj=utm +zone=45N +datum=WGS84 +ellps=WGS84"))
cost <- raster(cost)
cost <- trim(cost) #tried this line to remove the large number of NA values
but didn't fix anything
cT <- transition(cost, mean, 8)

#then I got the following error

Error in rbind(deparse.level, ...) :
  resulting vector exceeds vector length limit in 'AnswerType'

Any advice for a better process or a good work-around?  I am trying to stay
within the gdistance package because I am using many of the other commands
(shortestPath, costDistance, etc.)

I really appreciate any help anyone can lend with this problem.

Cheers,

IC

    [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
	[[alternative HTML version deleted]]

