# BBMM home range estimation

Hi trying to calculat brownian bridge homeranges using following code but am getting Error in optimize(contour.z, c(0, max(v)), tol = .Machine\$double.eps) : invalid 'xmin' value In addition: Warning message: In max(v) : no non-missing arguments to max; returning -Inf. Any help im only slowly learning r.

'''# Create Brownian Bridge Movement Models

# User defined input. Modify lines below.

##################################################################
X = "UTM_X" # The column name of your x coordinate
Y = "UTM_Y" # The column name of your y coordinate
loc.error = 15
maxlag = 600000
levels = c(95)
cell.size = 10 # change to NULL if area.grid is used
grid = NULL # if area.grid is created Null status will be removed
##################################################################

# method of grid creation is used.

##################################################################
LeftX=327700
RightX=327400
TopY=6117000
BottomY=611600
size=10
xcoords<-seq(from=LeftX, to=RightX, by=size)
ycoords<-seq(from=BottomY, to=TopY, by=size)
x<-rep(xcoords, times=length(ycoords))
y<-rep(ycoords, each=length(xcoords))
grid<-data.frame(x,y)
cell.size = NULL # over-rides earlier cell size if run
##################################################################
require(BBMM)
require(raster)
require(maptools)
require(rgdal)
for (i in 1:length(newlist_df)){
infile = newlist_df[[i]]
name = names(newlist_df[i])
BBMM<-brownian.bridge(infile[,X], infile[,Y],
time.lag = infile\$Timelag.min[-1],location.error=loc.error,
cell.size=cell.size, area.grid=grid)
x<-BBMM\$x[BBMM\$probability >= 0.00000001]
y<-BBMM\$y[BBMM\$probability >= 0.00000001]
z<-BBMM\$probability[BBMM\$probability >= 0.00000001]
tmp.df<-data.frame(x,y,z)
contours<-bbmm.contour(BBMM, levels= levels, locations =
cbind(infile[,X], infile[,Y]),plot = TRUE)
title(main=name)
out.raster <- rasterFromXYZ(tmp.df,crs=CRS(output.projection),
digits=2)
raster.contour <- rasterToContour(out.raster,levels=contours\$Z)
writeLinesShape(raster.contour, paste0(name,"_",levels,"BBMM"),
factor2char=TRUE)
cat(showWKT(proj4string(newlist[[1]])), file=paste0(name,"
",
levels,"_BBMM.prj"))
write.csv(tmp.df, file= paste0(name, "_BBMM.csv"))
tmp.xy<-tmp.df[,c(1:2)]
coordinates(tmp.df)<-tmp.xy
proj4string(tmp.df)<-CRS(output.projection)
writePointsShape(tmp.df, paste0(name,"BBMM_points"),
factor2char=TRUE)
cat(showWKT(proj4string(newlist[[1]])),
file=paste0(name,"BBMM_points.prj"))
}
rm(grid, infile, tmp.xy, BBMM, BottomY, cell.size, contours, i, LeftX, le
vels, loc.error, maxlag, name, out.raster, raster.contour, RightX, size, tmp.
df, TopY, X, x, xcoords, Y, y, ycoords, z) # remove unwanted objects'''

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.