DistanceDevelopment / dssd

Distance Sampling Survey Design
1 stars 1 forks source link

Problem calculating trackline length for segment designs #66

Closed LHMarshall closed 3 years ago

LHMarshall commented 3 years ago

Generates a subscript out of bounds error. This happens when the transect ID's do not start at 1 (perhaps all the first transect was outside the strata and removed in clipping).

#Load the unprojected shapefile
shapefile.name <- system.file("extdata", "TentsmuirUnproj.shp", package = "dssd")
sf.shape <- read_sf(shapefile.name)
# Define a European Albers Equal Area projection
proj4string <- "+proj=aea +lat_1=56 +lat_2=62 +lat_0=50 +lon_0=-3 +x_0=0
                +y_0=0 +ellps=intl +units=m"
# Project the study area on to a flat plane
projected.shape <- st_transform(sf.shape, crs = proj4string)

# Create the survey region in dssd
region.tm <- make.region(region.name = "Tentsmuir",
                         strata.name = c("Main Area", "Morton Lochs"),
                         shape = projected.shape)

#Test single value for number of samplers
design.tm <- make.design(region.tm,
                         transect.type = "line",
                         design = "segmentedgrid",
                         design.angle = c(-1,45),
                         samplers = 50,
                         seg.length = 200,
                         truncation = 25)

set.seed(122)
survey.tm1 <- generate.transects(design.tm)

Error in coord.mat[1, ] : subscript out of bounds 

4. rbind(coord.mat, coord.mat[1, ]) at calculate.trackline.segl.R#55
3. calculate.trackline.segl(transects[[strat]]) at Line.Transect.Design.R#208
2. generate.transects(design.tm) at generic.functions.R#53
1. generate.transects(design.tm)