Skip to contents

Initialize a set of particle locations for use in wind_trails().

Usage

generate_particles(
  x,
  n = 1000,
  sample = "random",
  equalarea = TRUE,
  epsg = 8857,
  expand = 0.25
)

Arguments

x

A wind_field object.

n

Positive integer giving the total number of particles in the grid. If sample = "random" the result will have this exact number of particles, while if sample = "grid" it will be approximate.

sample

Sampling scheme, either "random" (the default) to generate points at random locations, or "grid" to generate points on a regular grid.

equalarea

Logical indicating whether to generate points on an equal area basis (TRUE, the default) or in lon-lat space (FALSE, which over-samples higher-latitude regions).

epsg

EPSG code for the projection in which to generate points. Only used if equalarea = TRUE and sample = "grid". The default is 8857, the Equal Area projection.

expand

Proportion by which to expand the bounding box around x after projection, to capture the full domain in projected space. Only used if equalarea = TRUE and sample = "grid".

Value

A two-column matrix of x (longitude) and y (latitude) values, with a row for each particle.

Examples

field <- windscape_example("wind_field")
p <- generate_particles(field, n = 100)
head(p)
#>              x        y
#> [1,] -93.64991 24.81653
#> [2,] -83.89934 19.76607
#> [3,] -96.70346 25.62244
#> [4,] -82.48499 33.81829
#> [5,] -83.48341 28.87295
#> [6,] -96.09867 23.96857