decoupage cuts a territory into contiguous areas whose sizes stay within bounds. The name comes from “decoupage cartographique”, the term francophone national statistical offices use for delineating enumeration areas.
The package works at two scales. At the census scale, it groups building blocks into pre-census enumeration areas below a maximum population. At the survey scale, it merges small enumeration areas of a frame into primary sampling units, cuts large ones into segments, divides them into secondary units, and orders units so that neighbors stay close. Both rest on one contiguity graph and one size-constrained grouping engine, and the same functions serve every level.
The same functions build other area sampling frames, since they take any polygons and any additive size. An agricultural area frame groups land polygons into PSUs within land-use strata and cuts them into segments along lines field staff can find. A forest inventory groups stands into inventory blocks within management units, sized by area or growing stock.
The output is geometry, ids, sizes, an order and flags. decoupage never selects a sample and never attaches selection probabilities or weights. Sample sizes and allocation belong to svyplan, and selection to sondage and samplyr.
Installation
Install the development version from GitLab:
## install.packages("pak")
pak::pkg_install("gitlab::dickoa/decoupage")Which function
Each row starts from what you have and names the functions that give what you need. The same functions serve every level of a frame, so a PSU, a segment or an SSU is built with the calls that build an enumeration area.
| You have | You need | Functions |
|---|---|---|
| Admin units, or other boundary units, and the lines on the ground inside them | Blocks that nest in the units |
build_blocks(), delineate_settlements()
|
| Blocks and a raster of counts, buildings or points | The size of each block |
measure_units(), assign_points()
|
| Blocks and a settlement directory with points and codes | A territory for each settlement, made of whole blocks | assign_units() |
| Blocks or any units with sizes | Pre-census enumeration areas, inventory blocks or other groups within size bounds, or a given number of them with n
|
unit_graph(), split_units(), group_units(), dissolve_units()
|
| A frame of EAs with sizes | PSUs of a minimum size, with method = "merge"
|
group_units(), dissolve_units()
|
| PSUs or any other units | An order for systematic selection and zones | order_units() |
| Selected PSUs too large to list | Segments of a target size | split_units() |
| The blocks of the selected PSUs | SSUs of a minimum size within each PSU, with within = "psu"
|
group_units() |
| EAs and their graph | Supervision areas or work zones over them |
group_graph(), group_units()
|
| Any layer of units | Its defects, its nesting in a boundary layer and its sizes out of bounds | check_units() |
| A grouping | Its violations, shapes and boundaries |
check_groups(), group_metrics(), graph_lines()
|
| Two versions of a frame | Kept codes and the correspondence between them |
code_units(), crosswalk_units()
|
| A grouping and new boundary lines | The grouping nested in the new lines | renest_units() |
| A frame and field points | The areas where they disagree | audit_field() |
| Nothing yet | A population and its frames with a known truth, for experiments |
sim_population(), population_truth(), frame_truth()
|
| EAs with household counts, or households from a census | A population on them with a known truth |
populate_frame(), as_population()
|
| A population and an EA layer | The layer as a frame of that population | as_frame() |
Vocabulary
The functions speak of units, parts, groups, pieces, patches and sizes. This table gives their names in three uses.
| Term | Censuses and household surveys | Agricultural area frames | Forest inventories |
|---|---|---|---|
| unit | block, enumeration area | land polygon | stand, piece of a stand |
part (within), boundary |
admin unit, stratum | land-use stratum | management unit |
| patch | settlement | farm or field | stand |
| group | pre-census EA, PSU, SSU | PSU, segment | inventory block, crew block |
| piece | segment of a PSU | segment | piece of a large stand |
| size | persons, households, buildings | area, cropland | area, growing stock |
Example
The contiguity graph is built once from the polygons. group_units() then groups the units, and check_groups() tests the result. Here a grid of 80 cells, each holding about 60 people, is grouped into areas of 200 to 500 people.
library(decoupage)
cells <- sf::st_make_grid(
sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 1000, ymax = 800)),
cellsize = 100
)
cells <- sf::st_sf(geometry = cells, crs = 32630)
set.seed(1)
cells$pop <- rpois(nrow(cells), 60)
g <- unit_graph(cells)
cells$ea <- group_units(g, cells$pop, min = 200, max = 500,
target = 350, seed = 1)
range(tapply(cells$pop, cells$ea, sum))
#> [1] 261 386
nrow(check_groups(g, cells$ea, cells$pop, min = 200, max = 500))
#> [1] 0vignette("decoupage") works through both scales on open data for a window north of Yako, Burkina Faso, from roads and buildings to pre-census enumeration areas, then from a frame of enumeration areas to PSUs, their order and segments. vignette("recipes") gathers short recipes, such as fetching inputs from Overture Maps, an agricultural area frame, a forest inventory, reconciling a frame edited by hand and building a large area one admin unit at a time. The article The same population, different frames simulates a population with a known truth and compares the surveys drawn from three frames of different EA sizes.