build_blocks() cuts each boundary unit, such as an admin unit, a
land-use stratum or a forest stand, into the smallest polygons that
lines on the ground enclose, such as roads, tracks and paths, and
optionally the lines between settlement zones. The boundary lines are
always among the cutting lines, so every block lies inside one unit.
The blocks are the units group_units() then groups into enumeration
areas, PSUs or inventory blocks.
Usage
build_blocks(
boundary,
lines,
settlements = NULL,
smooth = NULL,
precision = 0.01,
min_area = 1,
min_width = 1
)Arguments
- boundary
An
sfobject of boundary unit polygons, such as admin units, in a projected CRS, one row per unit. Blocks nest in these units.- lines
The lines to cut along, as an
sforsfcobject of lines in the CRS ofboundary. Filter them beforehand to the classes that field staff can find on the ground. Dead ends are allowed and simply enclose nothing.- settlements
Settlement patches from
delineate_settlements(), or any polygons of settled land with an id columnsettlement, orNULL(default) for none. Polygons with the same id, or the parts of one multipolygon, are one settlement. Each unit is divided into zones, one per settlement, holding the land nearer to it than to any other, and the zone lines cut blocks too. In open country, where roads are few, this gives one block per settlement.- smooth
The tolerance, in CRS units, to which the lines between settlement zones are simplified, so they run straight rather than along the steps of the grid.
NULL(default) uses half the cell ofdelineate_settlements(), or no simplification for other polygons.0keeps the lines as computed.- precision
Coordinates are rounded to this, in CRS units, before the lines are noded, so that lines meeting within it share a node. The default
0.01is a centimeter in a metric CRS.- min_area
The smallest area a block may have, in the squared units of the CRS. A face below it, such as the sliver between two lines that run close together, joins a neighboring block (see Details). The default
1is a square meter in a metric CRS.0keeps every face.- min_width
The smallest mean width a block may have, in CRS units, the mean width being twice the area over the perimeter. A face below it, such as the strip between a road and a unit line drawn along it, joins a neighboring block (see Details). The default
1is a meter in a metric CRS.0keeps every face.
Value
An sf object with one row per block. Each block holds the
columns of the boundary unit it lies in, then unit (the row of
boundary), block (its number within the unit), zone (the
settlement whose zone holds it), settlement (the settlement whose
settled land it overlaps, NA for a block of open land), and
area. zone and settlement hold the ids of settlements with
their type, such as text codes or a factor, and are NA without
settlements. A
column area of boundary is replaced by the area of the block. A
column named unit, block, zone or settlement is an error, so
that a column such as a management unit is not lost. Pass
settlement, not zone, as the patch of unit_graph() so that
villages are kept whole while their fields stay free to join any
neighbor.
Details
Within each unit, the segments of the lines near it are joined with its
boundary, noded at every crossing and polygonized. Faces outside the
unit, such as a hole in it or land beyond its boundary, are dropped, so
the blocks of a unit cover it, up to the rounding of its vertices to
precision. A line that crosses the boundary
between two units is noded with the same segment on both sides, so the
blocks on either side share their vertices along it and form a
coverage. Units are processed one at a time, so each noding and
polygonizing works on one unit and the lines near it. The blocks of
every unit are kept until the end, so memory grows with the number of
blocks of the layer.
Lines that run close together, such as two carriageways or a road
along a unit line, enclose slivers no one can stand in. Each face below
min_area, or narrower on average than min_width, joins the face of
the same unit it shares the longest boundary with, the smallest first,
so the blocks still cover the unit. A face with no neighbor in its
unit, such as a unit smaller than min_area, stays. A unit line drawn
along a road crosses it again and again, and each stretch of road
inside the unit cuts off a strip. On the 39,241 faces of the eight LGAs
of The Gambia, cut by 104,884 lines, 17 were below 1 m2 and 98 were
narrower than 1 m on average. In three districts of Rwanda, whose
village lines often follow roads, 6,541 of 33,597 faces were narrower
than 1 m. None of them held a building.
Settlement zones follow the Euclidean allocation of the WorldPop preEA
tool, in which each point of a unit goes to the nearest settlement. They are
computed from points along each settlement's outline, at most cell
apart for patches from delineate_settlements(), as the Voronoi cells of
those points dissolved per settlement. The lines between zones are then
simplified to smooth between the points where three zones meet, so
neighboring zones keep a common line.
References
Qader, S. H., Kuepie, K., and Tatem, A. J. (2024). Automatic national census pre-Enumeration Areas for Zimbabwe in 2021, version 1.0. WorldPop, University of Southampton. doi:10.5258/SOTON/WP00797
See also
delineate_settlements() for the settlements, unit_graph()
for the graph of the blocks.
Other input functions:
assign_points(),
assign_units(),
delineate_settlements(),
measure_units()
Examples
commune <- sf::st_sf(
id = "C1",
geometry = sf::st_sfc(
sf::st_polygon(list(rbind(
c(0, 0), c(1000, 0), c(1000, 800), c(0, 800), c(0, 0)
))),
crs = 32630
)
)
roads <- sf::st_sfc(
sf::st_linestring(rbind(c(-50, 300), c(1050, 350))),
sf::st_linestring(rbind(c(500, -50), c(480, 850))),
sf::st_linestring(rbind(c(700, 350), c(700, 600))),
crs = 32630
)
blocks <- build_blocks(commune, roads)
blocks
#> Simple feature collection with 4 features and 6 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 0 ymin: 0 xmax: 1000 ymax: 800
#> Projected CRS: WGS 84 / UTM zone 30N
#> id unit block zone settlement area geometry
#> 1 C1 1 1 NA NA 155285 POLYGON ((498.8889 0, 0 0, ...
#> 2 C1 1 2 NA NA 169715 POLYGON ((1000 347.7273, 10...
#> 3 C1 1 3 NA NA 238285 POLYGON ((481.1111 800, 100...
#> 4 C1 1 4 NA NA 236715 POLYGON ((0 302.2727, 0 800...