Skip to contents

A geolist is a list of geofields that are on the same domain. The main purpose of a geolist is to be used as a column in a data frame.

Usage

geolist(..., domain = NULL)

is_geolist(x)

variance(x, na.rm = FALSE, ...)

std_dev(x, na.rm = FALSE, ...)

Arguments

...

geofields or a list containing geofields

domain

Typically not used, since the domain will be obtained from the geofields

x

An object

na.rm

Logical. Whether to remove NAs before calculation.

Value

A list of geofields on the same domain with class harp_geolist

Details

A number of methods are available for geolists that reduce the geolist to a geolist containing a single geofield. These include:

  • mean - element-wise mean of the geolist

  • std_dev - element-wise standard deviation of the geolist

  • variance element-wise variance of the geolist

  • min - element-wise minimum of the geolist

  • max - element-wise maximum of the geolist

  • cumsum - element-wise cumulative sum of the geolist

  • cumprod - element-wise cumulative product of the geolist

  • cummin - element-wise cumulative minimum of the geolist

  • cummax - element-wise cumulative maximum of the geolist

  • any - element-wise any of a logical geolist is TRUE

  • all - element-wise all of a logical geolist is TRUE

Note that the R stats functions sd and var cannot be used on geolists since they are not implemented as methods, so std_dev and variance must be used instead.

In addition most of R's generic math and logic functions work with geolists.

is_geolist() checks if the argument is a valid geolist.

Examples

# Define a domain
my_domain <- define_domain(10, 60, 300, 10000)

# geolist from indivdual geofields
geolist(
  geofield(array(rnorm(300 * 300), c(300, 300)), domain = my_domain),
  geofield(array(rnorm(300 * 300), c(300, 300)), domain = my_domain)
)
#> <harp_geolist[2]>
#> [[1]] <numeric geofield [300 x 300] Min = -4.095 Max = 4.173 Mean = 0.001>
#> [[2]] <numeric geofield [300 x 300] Min = -4.764 Max = 4.454 Mean = -0.004>

# geolist from a list of geofields
gfld <- lapply(
  1:10,
  function(x) geofield(
    array(runif(300 * 300), c(300, 300)), domain = my_domain
  )
)
glst <- geolist(gfld)
glst
#> <harp_geolist[10]>
#>  [[1]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.501>
#>  [[2]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.500>
#>  [[3]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.501>
#>  [[4]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.499>
#>  [[5]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.499>
#>  [[6]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.499>
#>  [[7]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.500>
#>  [[8]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.499>
#>  [[9]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.499>
#> [[10]] <numeric geofield [300 x 300] Min = 0.000 Max = 1.000 Mean = 0.501>

# Summarise geolist to a single geofield
mean(glst)
#> <harp_geolist[1]>
#> [[1]] <numeric geofield [300 x 300] Min = 0.156 Max = 0.849 Mean = 0.500>
std_dev(glst)
#> <harp_geolist[1]>
#> [[1]] <numeric geofield [300 x 300] Min = 0.085 Max = 0.448 Mean = 0.285>
variance(glst)
#> <harp_geolist[1]>
#> [[1]] <numeric geofield [300 x 300] Min = 0.007 Max = 0.201 Mean = 0.083>
min(glst)
#> <harp_geolist[1]>
#> [[1]] <numeric geofield [300 x 300] Min = 0.000 Max = 0.688 Mean = 0.090>
max(glst)
#> <harp_geolist[1]>
#> [[1]] <numeric geofield [300 x 300] Min = 0.305 Max = 1.000 Mean = 0.909>
any(glst > 0.9)
#> <harp_geolist[1]>
#> [[1]] <logical geofield [300 x 300] TRUE: 58779 FALSE: 31221>
all(glst > 0.25)
#> <harp_geolist[1]>
#> [[1]] <logical geofield [300 x 300] TRUE: 4931 FALSE: 85069>