<span style="font-family: courier new,monospace;"><span style="font-family: arial,helvetica,sans-serif;">When I specify eps=25 (m resolution) in a call to distmap...</span><br><br><span style="color: rgb(0, 0, 102);">> library(spatstat)</span><br style="color: rgb(0, 0, 102);">
<span style="color: rgb(0, 0, 102);">> temp <- data.frame(x=-670049.2, y=752814.6, X2=-669961.9, Y2=752648.2)</span></span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);"><span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> subwin<-owin(xrange=c(-100, 100) + sort(c(temp$x, temp$X2)), yrange=c(-100, 100) + sort(c(temp$y, temp$Y2)))</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);">
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> trajpsp<-psp(temp$x,temp$y, temp$X2, temp$Y2, subwin, check=TRUE)</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);">
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> plot(trajmap<-distmap(trajpsp, eps=25))</span><br style="color: rgb(0, 0, 102);"><span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> trajmap$xstep</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);">
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">[1] 23.94167</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);"><span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> trajmap$ystep</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);">
<span style="font-family: courier new,monospace;"><span style="color: rgb(0, 0, 102);">[1] 24.42667</span><br><br><span style="font-family: arial,helvetica,sans-serif;">...The resulting resolution is slightly different than 25x25 metres. So now when I use it as a mask:</span></span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> trajmap$v<-ifelse(trajmap$v>50, 0, 1)</span><br style="color: rgb(0, 0, 102);"><span style="font-family: courier new,monospace;"><span style="color: rgb(0, 0, 102);">> library(maptools)</span><br>
<br><span style="font-family: arial,helvetica,sans-serif;">...and convert it to a RasterLayer for matrix algebra with another raster</span><br style="font-family: arial,helvetica,sans-serif;"></span><span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> trajrast<-raster(<a href="http://as.SpatialGridDataFrame.im">as.SpatialGridDataFrame.im</a>(from=trajmap))<br>
> tempmap<-crop(habmap, extent(trajrast)) # tempmap.grd is attached<br>> top<-table(getValues(tempmap*trajrast))<br>Error in compare(c(e1, e2)) : Different bounding box<br>Error in getValues(tempmap * trajrast) : <br>
error in evaluating the argument 'x' in selecting a method for function 'getValues'</span><br><br>...it doesn't work because the resolution is not exactly equal. Now I can sometimes trick it when the number of rows and cells are still equal, BUT...<br>
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">extent(trajrast)<-extent(tempmap)</span><br style="color: rgb(0, 0, 102);"><span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">> top<-table(getValues(tempmap*trajrast))</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);">
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">Error in compare(c(e1, e2)) : nrows different</span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);"><span style="font-family: courier new,monospace; color: rgb(0, 0, 102);">Error in getValues(tempmap * trajrast) : </span><br style="font-family: courier new,monospace; color: rgb(0, 0, 102);">
<span style="font-family: courier new,monospace; color: rgb(0, 0, 102);"> error in evaluating the argument 'x' in selecting a method for function 'getValues'</span><br><br>...This is not always the case! <br>
<br>How can I prevent the numbers of rows and columns from being so slightly different because of a minor different in resolution? Otherwise put, how can I make the actual resolution of my distmap image exactly 25m as desired?<br>
<br>Tyler<br><br><br><br><br>