It looks like that when you set a value of a RasterLayer's cell to TRUE,
the object gets coerced to numeric. What if you made your objects like
this? I couldn't run your code because I'm missing an object total. Good
luck.

origin <- matrix(rep(FALSE, ncell(map.test)), ncol = ncol(map.test))
goal <- origin
origin[93] <- TRUE
goal[9] <- TRUE
origin <- raster(origin)
goal <- raster(goal)

Cheers,
Roman



On Wed, Jan 16, 2013 at 1:21 PM, Josephine Walker <[email protected]>wrote:

> Hello everyone,
>
> I'm new to this list and to using R for geographical data analysis. I am
> playing around with the gdistance package but have a small problem:
>
> I am trying to use a RasterLayer to define origin and goal points for the
> passage function, which I believe is possible based on the documentation:
>
> origin
> SpatialPoints, matrix or numeric object with coordinates or RasterLayer
> object with origin cells set to TRUE
>
> goal
> SpatialPoints, matrix or numeric object with coordinates or RasterLayer
> object with origin cells set to TRUE
>
> Here is a basic idea of what I'm doing:
>
> ####################################
> map.test <- raster(ncol=10,nrow=10)
> map.test[] <- 100
>
> origin <- raster(ncol=ncol(map.test),nrow=nrow(map.test))
> origin[] <- FALSE
> origin[93] <- TRUE
> goal <- raster(ncol=ncol(map.test),nrow=nrow(map.test))
> goal[] <- FALSE
> goal[9] <- TRUE
>
> tran.test <- transition(map.test,transitionFunction=mean,directions=8)
>
> passage(tran.test, origin, goal,theta=0,totalNet=total)
>
> and this gives the error message:
> Error in which(getValues(origin)) : argument to 'which' is not logical
> ##################################
>
> Any ideas what I'm doing wrong?
>
> Thanks very much
> Josephine
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> [email protected]
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
In God we trust, all others bring data.

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to