Description Usage Arguments Details Value Examples

View source: R/rstox_spatial.r

Get polygon area and convert to or from geographic and Cartesian coordinates. The strata are converted to Cartesian coordinates using a common projection that preserves distance (azimuthal equal distance projection, aeqd in the proj4 library).

1 2 3 4 5 6 7 8 9 10 11 12 | ```
surveyPlanner(projectName, parameters = NULL, type = "Parallel",
bearing = "N", rev = FALSE, retour = FALSE, toursFirst = FALSE,
hours = 240, nmi = NULL, t0 = NULL, knots = 10, seed = 0,
angsep = 1/6, distsep = NULL, plot = FALSE, margin = NULL,
shapenames = list(longitude = "long", latitude = "lat", stratum = "id"),
equalEffort = FALSE, byStratum = TRUE, strata = "all")
plotStratum(x, zoom = 4, transect = TRUE, centroid = NULL,
transport_alpha = 0.1, google = FALSE, margin = 0.5,
aspectratio = NULL, xlab = "longitude", ylab = "latitude")
readStrataPolygons(projectName)
``` |

`projectName` |
The name or full path of the project, a baseline object (as returned from |

`parameters` |
Optional named list of parameters overriding the inputs "type", "bearing", "retour", "hours", "knots", "nmi", "seed" or "t0". This list is returned from |

`type` |
The type of the transects, repeated to the number of stratums. See details for possible values. Case insensitive. |

`bearing` |
The survey bearing of each transect, given in one of 4 ways: (1) by codes "N", "NW", "W", "WS", "S", "SE", "E", "NE", (2) as angles counter clockwise from EAST on degrees, (3) as a string "along" or "across" the stratum orientation as obtained by the principal components of the stratum borders after populating with 1000 points with nearly equal separation along the border in geographic corrdinates, or (4) as a data frame with columns "lon_start", "lon_stop", "lat_start", "lat_stop" defining the angles between a start and end point for each stratum. |

`rev` |
Logical: If TRUE, the bearing calculated by the funciton when bearing = "along" or "across" is reversed, i.e., going from East to West instead of West to East. |

`retour` |
Logical: If TRUE, continue with the transects back to the start point of the stratum. |

`toursFirst` |
Logical: If TRUE, do all tours first followed by the retours (only effective if retour is TRUE). |

`hours, nmi` |
The time/traveled distance to spend in each stratum, given in hours/nautical miles (repeated to the number of strata), where |

`t0` |
The start time of the survey, set to Sys.time() by default. |

`knots` |
The speed to use in the stratum, given in knots. |

`seed` |
The seed(s) to use for the random transects. If not given as a vector of length equal to the number of strata, random seed are drawn using |

`angsep` |
The separation in degrees of points populating the stratum polygons (geographical coordinates longitude, latitude). Low values preserve the stratum borders when converting to Cartesian coordinates. |

`distsep` |
The separation in nautical miles of points populating the transects in Cartesian coordinates before converting back to geographical coordinates. When given, this parameter preserves the shortest travel distance (great-circle distances) of the transects (inducing curved lines in geographical coordinates). |

`plot` |
Deprecated: Plots the transects in Cartesian coordintes. Use |

`margin` |
The margin to accept for deviation between input and output total travelled distance. Setting this may result in unequal coverage, since the forcing the total traveled distance towards a fixed value may force specific paths due to the shape of the stratum. Rather, increase the input |

`shapenames` |
A list of length 3 giving the names of the longitude, latitude and stratum column in the shape files. |

`equalEffort` |
Logical: If TRUE, assign effort proportional to the area of each stratum. |

`byStratum` |
Logical: If FALSE, include the transport between strata in the total traveled distance given in $Survey of the output. |

`strata` |
Specification of the strata to include, either given as the string "all", implying all strata to be used, og a index vector as given to "[]" (negative values may be used to exclude specific strata). |

`x` |
The output from |

`zoom` |
The zoom to use for google maps |

`transect` |
Logical: If TRUE, plot the transects. |

`centroid` |
Logical: If TRUE, plot the centroid of the strata. |

`transport_alpha` |
The transparency to use for the transport paths. |

`google` |
Logical: If TRUE, download Google maps. |

`aspectratio` |
The aspect ratio of the plot, adjusted automatically by default. |

`xlab` |
The x label for the plot. |

`ylab` |
The y label for the plot. |

Strindberg and Buckland (2004): Strindberg, S., & Buckland, S. T. (2004). Zigzag survey designs in line transect sampling. Journal of Agricultural, Biological, and Environmental Statistics, 9(4), 443 The following types are implemented:

`surveyPlanner`

returns a list of the following elements:

- "Parallel"
"Parallel transects"

- "EqAngZZ"
"Equal angle zigzag sampler (not implemented), Strindberg and Buckland (2004)"

- "EqSpZZ"
"Equal space zigzag sampler, Strindberg and Buckland (2004)"

- "AdjAngZZ"
"Adjusted angle zigzag sampler (not implemented), Strindberg and Buckland (2004)"

- "RectEnclZZ"
"Rectangular enclosure zigzag sampler, Harbitz and Holmin (2018)"

- "CurvEnclZZ"
"Curved enclosure zigzag sampler (not implemented), Harbitz and Holmin (2018)"

`surveyPlanner`

returns a list of the following elements:

- "transects"
"A data frame with the geographic and Cartesian transect coordinates for all strata, along with start, mid and stop time and sailed distance"

- "totalSailedDist"
"A data fram with total, transect, transport and input (nmi) sailed distance, also given in percent of 'nmi'."

- "lonlat"
"The input stratum polygons (longitude, latitude) in a list with one matrix per stratum"

- "parameters"
"A list of parameters for each stratum: type, bearing, retour, hours, knots, nmi, seed"

- "proj"
"The projection string used to convert from (longitude, latitude) to (x, y)"

- "area"
"The area og each polygon in square nautical miles"

- "centroid"
"The centroid of the strata, used in the projection"

- "strata"
"The stratum names"

`polyArea`

returns area in nmi squared, and `matrix2multipolygon`

returns a MULTIPOLYGON wkt.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ```
# Generate parallel transects with equal effort in each stratum (proportional to area):
projectName <- "Test_Rstox"
system.time(Parallel <- surveyPlanner(projectName=projectName, type="Parallel", bearing="N",
nmi=2000, knots=10, seed=0, equalEffort=TRUE))
dev.new()
plotStratum(Parallel)
# Running surveyPlanner() on a project takes some time, since the project has to be opened and
# the process data read to obtain the strata. A quicker way is to specify the strata definitions
# directly, either as the path to a file such as
# file.path(dirname(getProjectPaths()$projectRoot), "polygon", "norwegian_sea2014.txt"),
# or as a folder or vector of paths to shapefiles:
# This produces a different strata system than that in the Test_Rstox project:
system.time(Parallel <- surveyPlanner(projectName=file.path(dirname(getProjectPaths()$projectRoot),
"polygon", "norwegian_sea2014.txt"), type="Parallel", bearing="N",
nmi=2000, knots=10, seed=0, equalEffort=TRUE))
dev.new()
plotStratum(Parallel)
# Write the transects to one csv file (to write one file per stratum use byStratum=TRUE).
# Use ext="nc" to write to a NetCDF4 file. Use 'dir' to specify the directory in which to place
# the file(s) (otherwise the files are placed in the R Report directory of the project):
filename <- writeTransects(Parallel, projectName=projectName, byStratum=FALSE)
filename
# Zigzag with equal coverage probability:
system.time(Zigzag <- surveyPlanner(projectName=projectName, type="RectEnclZZ", bearing="N",
nmi=2000, knots=10, seed=0, equalEffort=TRUE))
dev.new()
plotStratum(Zigzag)
# The parallel survey use 23.39 percent of sailing distance for transport between transects,
# whereas the zigzag survey use 10.76 percent.
Parallel$Survey
Zigzag$Survey
# Reduce effort in the last three strata, e.g. due to lost time due to bad weather in stratum 1:
# Note that the parameter 'nmi' must be NULL (default) to effectively change the 'hours', since
# 'nmi', when specified, har precedence over 'hours'.
# Also, the parameter 'equalEffort' must be FALSE (default) since TRUE implies recalculating
# the distance to traveled in each stratum so that this distance is proportional to stratum area:
hours <- Parallel$parameters$hours
hours[2:4] <- hours[2:4] - 50
system.time(Parallel2 <- surveyPlanner(projectName=projectName, type="Parallel", bearing="N",
knots=10, seed=0, hours=hours))
dev.new()
plotStratum(Parallel2)
# Tour-retour zigzag in stratum 1 and 3:
system.time(Zigzag2 <- surveyPlanner(projectName=projectName, type="RectEnclZZ", bearing="N",
nmi=2000, knots=10, seed=0, equalEffort=TRUE, retour=c(TRUE, FALSE, TRUE, FALSE)))
dev.new()
plotStratum(Zigzag2)
# Populate the transects with points separated by 10 nmi specified by the 'distsep' parameter,
# for visualizing the true track along the great-circle:
system.time(Zigzag3 <- surveyPlanner(projectName=projectName, type="RectEnclZZ", bearing="N",
nmi=2000, knots=10, seed=0, equalEffort=TRUE, retour=c(TRUE, FALSE, TRUE, FALSE), distsep=10))
dev.new()
plotStratum(Zigzag3)
# Write the transects to a NetCDF4 file in the output folder of the project (alternatively specify
# the directory using 'dir', or the filenames using 'filenames'. Also use 'prefix' or 'suffix'
# to add info to the file names):
writeTransects(Zigzag3, projectName, ext="nc")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.