It is often impractical, inefficient, or impossible to perform an operation on a vector of geometries with all the geometries loaded into memory at the same time. These functions help generalize the pattern of split-apply-combine to one or more handlers recycled along a common length. These functions are designed for developers rather than users and should be considered experimental.

wk_chunk_strategy_single()

wk_chunk_strategy_feature(n_chunks = NULL, chunk_size = NULL)

wk_chunk_strategy_coordinates(n_chunks = NULL, chunk_size = NULL, reduce = "*")

Arguments

n_chunks, chunk_size

Exactly one of the number of chunks or the chunk size. For wk_chunk_strategy_feature() the chunk size refers to the number of features; for wk_chunk_strategy_coordinates() this refers to the number of coordinates as calculated from multiple handleables using reduce.

reduce

For wk_chunk_strategy_coordinates() this refers to the function used with Reduce() to combine coordinate counts from more than one handleable.

Value

A function that returns a data.frame with columns from and to when called with a handleable and the feature count.

Examples

feat <- c(as_wkt(xy(1:4, 1:4)), wkt("LINESTRING (1 1, 2 2)"))
wk_chunk_strategy_single()(list(feat), 5)
#>   from to
#> 1    1  5
wk_chunk_strategy_feature(chunk_size = 2)(list(feat), 5)
#>   from to
#> 1    1  2
#> 2    3  4
#> 3    5  5
wk_chunk_strategy_coordinates(chunk_size = 2)(list(feat), 5)
#>   from to
#> 1    1  2
#> 2    3  4
#> 3    5  5