group_metrics() returns one row per group with its size, its area
and four measures of its shape, so groups that are too large, empty,
thin or broken show before a frame goes to the field. With the graph,
it also splits each group's boundary by what field staff meet along
it, a within line, a barrier, or the boundary with another group on
a visible line or across open ground, and reports whether another
group encloses it.
Arguments
- x
An
sfobject (orsfc) of polygons, the layer the groups were built from.- group
The group of each unit, as a column name of
xor an atomic vector, with noNA.- size
The size of each unit, as a column name of
xor a numeric vector, summed per group, orNULL(default) for none.- graph
The
unit_graph()ofx, orNULL(default). It adds the columns that read adjacency and boundaries. It must be built fromxitself, in the same row order. Only its number of units is checked, so a graph of a reordered or edited layer gives wrong results without an error.- is_coverage
Passed to
dissolve_units(). UseFALSEfor a layer whose units overlap or were digitized separately.
Value
A data frame with one row per group, in order of first appearance, holding
group,units(the count of units),sizewhensizeis given,areaandperimeter, in the units of the CRS.parts, the count of separate polygons of the dissolved group, which is 1 for a contiguous group.ipq, the isoperimetric quotient4 pi area / perimeter^2.convexity, the area over the area of the convex hull.reock, the area over the area of the smallest enclosing circle.elongation, the longest distance across the group over the diameter of the circle of the same area.
With graph, also
within, the part of the layer the group lies in (seeunit_graph()), andneighbors, the count of adjacent groups.outer, the part of the perimeter on awithinline or the edge of the layer,barrier, the part on a barrier line, andbetween, the part shared with other groups.visibleandinvisible, the part ofbetweenon a visible line and the rest,NAfor a graph built withoutvisiblelines, andinvisible_share,invisibleover the perimeter.enclosed,TRUEfor a group whose whole boundary is shared with one other group.
Details
The first three shape measures lie between 0 and 1, higher for more
compact shapes, and elongation is 1 for a disk and grows as the shape
stretches. They answer different questions. The isoperimetric quotient
(Polsby and Popper 1991) penalizes rough edges as much as elongation,
so groups of blocks that follow streets score low even when they are
round. Convexity reads dents and holes, and the Reock ratio (Reock
1961) reads how far the group spreads from its center. Elongation is
the measure Qader et al. (2021) propose, as it does not depend on size.
An enclosed group, a donut hole in the group around it, is valid but awkward in the field, since the field worker of the outer group walks around it. AZTool and the WorldPop tool flag the same case.
The boundary columns come from the graph alone, so they apply to any
grouping of its units, published ones included. outer, barrier and
between add up to the perimeter in the graph, which differs from
perimeter only by contacts too short to make an edge (see
min_shared in unit_graph()). A within line is counted in outer
whether or not it follows a road. No group crosses it, so that part of
the boundary is fixed before any grouping, and invisible holds only
the part a grouping can change.
The CV of sizes per part, the dispersion that drives unequal weights
in a sample drawn from the frame, is tapply(size, within, sd) / tapply(size, within, mean) on the result.
References
Polsby, D. D., and Popper, R. D. (1991). The third criterion: Compactness as a procedural safeguard against partisan gerrymandering. Yale Law and Policy Review, 9(2), 301-353.
Qader, S., Lefebvre, V., Tatem, A. J., et al. (2021). Semi-automatic mapping of pre-census enumeration areas and population sampling frames. Humanities and Social Sciences Communications, 8, 3. doi:10.1057/s41599-020-00670-0
Reock, E. C. (1961). A note: Measuring compactness as a requirement of legislative apportionment. Midwest Journal of Political Science, 5(1), 70-74. doi:10.2307/2109043
See also
check_groups() for the rules a grouping meets,
graph_lines() to draw the graph.
Other checks:
audit_field(),
check_groups(),
check_units(),
graph_lines()
Examples
cells <- sf::st_make_grid(
sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 600, ymax = 400)),
cellsize = 100
)
cells <- sf::st_sf(geometry = cells, crs = 32630)
cells$pop <- rep(c(40, 60, 80), 8)
road <- sf::st_sfc(
sf::st_linestring(rbind(c(300, 0), c(300, 400))),
crs = 32630
)
g <- unit_graph(cells, visible = road)
ea <- group_units(g, cells$pop, max = 600, seed = 1)
m <- group_metrics(cells, ea, size = cells$pop, graph = g)
m
#> group units size area perimeter parts ipq convexity reock
#> 1 1 9 540 90000 1200 1 0.7853982 1.0000000 0.6366198
#> 2 2 6 360 60000 1000 1 0.7539822 1.0000000 0.5876490
#> 3 3 9 540 90000 1600 1 0.4417865 0.8571429 0.2864789
#> elongation within neighbors outer barrier between visible invisible
#> 1 1.253314 1 2 600 0 600 300 300
#> 2 1.304491 1 2 500 0 500 200 300
#> 3 1.868330 1 2 900 0 700 100 600
#> invisible_share enclosed
#> 1 0.250 FALSE
#> 2 0.300 FALSE
#> 3 0.375 FALSE
# Without the visible weight, groups are cut across open ground
ea0 <- group_units(g, cells$pop, max = 600, visible_weight = 0,
seed = 1
)
group_metrics(cells, ea0, graph = g)[, c("group", "invisible_share")]
#> group invisible_share
#> 1 1 0.250
#> 2 2 0.300
#> 3 3 0.375
# Size dispersion per part
tapply(m$size, m$within, stats::sd) / tapply(m$size, m$within, mean)
#> 1
#> 0.2165064