Thank you Jacob for pointing out the obvious I missed. Looks like distance() will do what I want.
r <- raster(ncol=36,nrow=36, projs = "+proj=NA") r[] <- NA r[500] <- 1 dist <- distance(r) plot(dist) Michael, compare this output to (notice +proj=NA - see Roberts comments here<http://r-sig-geo.2731867.n2.nabble.com/assigning-raster-cell-values-based-on-predefined-criteria-tp4929775p4945952.html> ): r <- raster(ncol=36,nrow=36) r[] <- NA r[500] <- 1 dist <- distance(r) plot(dist) Cheers, Roman On Tue, Jun 22, 2010 at 11:45 AM, Jacob van Etten <jacobvanet...@yahoo.com>wrote: > Hi Roman, > > Nice picture. > > The help file says: > > "Distances are calculated by summing local distances between cells, which > are connected with their neighbours in 8 directions." > > Hence, you get a hexagonal shape if the grid doesn´t have any "islands" the > shortest routes have to avoid. > > Perhaps distance() is what you really want? > > Otherwise, costDistance() in gdistance may do what you want. > > Best, > > Jacob. > > --- On *Tue, 6/22/10, Roman Luštrik <roman.lust...@gmail.com>* wrote: > > > From: Roman Luštrik <roman.lust...@gmail.com> > Subject: [R-sig-Geo] distances values from a point exhibit a hexagon-like > distribution > To: "r-sig-geo" <r-sig-geo@stat.math.ethz.ch> > Date: Tuesday, June 22, 2010, 9:36 AM > > Can someone explain to me why values of distances from a point are not in a > uniform, circle-like fashion, but rather form a hexagon shape (see > image<http://imagepaste.nullnetwork.net/viewimage.php?id=1075>)? > Here is the code I'm using to produce this plot (kudos to > Robert< > http://r-sig-geo.2731867.n2.nabble.com/assigning-raster-cell-values-based-on-predefined-criteria-td4929775.html#a4929775 > >). > Raster projection is "+projs = NA". > > rst.poly <- polygonsToRaster(circle.polygon, rst) #circle.polygon is the > polygon I'm overlaying, rst is the raster > rst.lines <- linesToRaster(circle.polygon, rst) > rst.lines[rst.lines > 0] <- 0 > rst.point <- pointsToRaster(rst, xy[[i]][j,]) #xy is the point from where > the distances are calculated > rst.cover <- cover(rst.point, rst.lines) > rst.grid <- gridDistance(rst.cover) > rst.grid[!is.na(rst.lines)] <- NA > plot(rst.grid) > > > Cheers, > Roman > > > -- > In God we trust, all others bring data. > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch<http://mc/compose?to=r-sig-...@stat.math.ethz.ch> > 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 R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo