Skip to contents

Split grid list to a nested list of row-wise data frames

Usage

par_split_list(gridlist)

Arguments

gridlist

list. Output of par_pad_grid or par_pad_balanced

Value

A nested list of data frames or WKT strings.

Details

If the input is a data frame, the function will return a list of two data frames: original and padded. If the input is a WKT vector, the function will return a list of two WKT strings: original and padded.

Examples

library(sf)
library(terra)
options(sf_use_s2 = FALSE)

ncpath <- system.file("shape/nc.shp", package = "sf")
nc <- read_sf(ncpath)
nc <- st_transform(nc, "EPSG:5070")
nc_comp_region <-
  par_pad_grid(
    nc,
    mode = "grid",
    nx = 4L, ny = 2L,
    padding = 10000)
#> Switch sf class to terra...
#> Switch terra class to sf...
par_split_list(nc_comp_region)
#> [[1]]
#> [[1]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1054293 ymin: 1348025 xmax: 1249095 ymax: 1518631
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 1 POLYGON ((1054293 1348025, ...       1
#> 
#> [[1]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1044293 ymin: 1338025 xmax: 1259095 ymax: 1528631
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 1       1 POLYGON ((1044293 1338025, ...
#> 
#> 
#> [[2]]
#> [[2]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1249095 ymin: 1348025 xmax: 1443896 ymax: 1518631
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 2 POLYGON ((1249095 1348025, ...       2
#> 
#> [[2]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1239095 ymin: 1338025 xmax: 1453896 ymax: 1528631
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 2       2 POLYGON ((1239095 1338025, ...
#> 
#> 
#> [[3]]
#> [[3]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1443896 ymin: 1348025 xmax: 1638697 ymax: 1518631
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 3 POLYGON ((1443896 1348025, ...       3
#> 
#> [[3]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1433896 ymin: 1338025 xmax: 1648697 ymax: 1528631
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 3       3 POLYGON ((1433896 1338025, ...
#> 
#> 
#> [[4]]
#> [[4]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1638697 ymin: 1348025 xmax: 1833498 ymax: 1518631
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 4 POLYGON ((1638697 1348025, ...       4
#> 
#> [[4]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1628697 ymin: 1338025 xmax: 1843498 ymax: 1528631
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 4       4 POLYGON ((1628697 1338025, ...
#> 
#> 
#> [[5]]
#> [[5]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1054293 ymin: 1518631 xmax: 1249095 ymax: 1689236
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 5 POLYGON ((1054293 1518631, ...       5
#> 
#> [[5]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1044293 ymin: 1508631 xmax: 1259095 ymax: 1699236
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 5       5 POLYGON ((1044293 1508631, ...
#> 
#> 
#> [[6]]
#> [[6]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1249095 ymin: 1518631 xmax: 1443896 ymax: 1689236
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 6 POLYGON ((1249095 1518631, ...       6
#> 
#> [[6]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1239095 ymin: 1508631 xmax: 1453896 ymax: 1699236
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 6       6 POLYGON ((1239095 1508631, ...
#> 
#> 
#> [[7]]
#> [[7]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1443896 ymin: 1518631 xmax: 1638697 ymax: 1689236
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 7 POLYGON ((1443896 1518631, ...       7
#> 
#> [[7]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1433896 ymin: 1508631 xmax: 1648697 ymax: 1699236
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 7       7 POLYGON ((1433896 1508631, ...
#> 
#> 
#> [[8]]
#> [[8]]$original
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1638697 ymin: 1518631 xmax: 1833498 ymax: 1689236
#> Projected CRS: NAD83 / Conus Albers
#>                         geometry CGRIDID
#> 8 POLYGON ((1638697 1518631, ...       8
#> 
#> [[8]]$padded
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: 1628697 ymin: 1508631 xmax: 1843498 ymax: 1699236
#> Projected CRS: NAD83 / Conus Albers
#>   CGRIDID                       geometry
#> 8       8 POLYGON ((1628697 1508631, ...
#> 
#>