audit_field() compares points collected in the field, such as GPS
readings of structures or households from a listing, with the areas of
a frame. It reports the points that fall outside every area, with the
nearest one, and for each area the field count against its estimated
size, so the areas whose estimate was furthest off, or that the field
did not reach, are found first.
Arguments
- x
An
sfobject of the frame's areas, in a projected CRS.- points
An
sforsfcof field points in the CRS ofx.- size
The estimated size of each area, as a column name of
xor a numeric vector, orNULL(default) to report field counts only.- weight
The count each point stands for, such as households in a structure, as a column name of
pointsor a numeric vector, orNULL(default) for 1 each. It is not a survey weight.- flag
The relative gap between the field count and the estimate from which an area is flagged. The default
0.5flags counts below half or above one and a half times the estimate.
Value
A list with
areas, a data frame with one row per area ofx, holdingrowandfield(the weight of its points). Withsize, it also holdssize,difference(fieldminussize),ratio(fieldoversize,NAfor an estimate of 0),rank(1 for the largest absolute difference) andflag.outside, ansfobject of the points in no area, withpoint(their row inpoints),nearest(the row of the nearest area) anddistance.
Details
Points are assigned by assign_points(), so a point on the line
between two areas counts once, whatever the row order. An area with an
estimate but no field point is flagged, as an area the team may have
missed. The distance of a point outside every area to the nearest one
tells a GPS error of a few meters from a structure listed in the wrong
place.
See also
check_units() for the frame itself, assign_points().
Other checks:
check_groups(),
check_units(),
graph_lines(),
group_metrics()
Examples
cells <- sf::st_make_grid(
sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 300, ymax = 100)),
cellsize = 100
)
eas <- sf::st_sf(households = c(4, 2, 3),
geometry = sf::st_set_crs(cells, 32630))
gps <- sf::st_sfc(
sf::st_point(c(20, 50)), sf::st_point(c(40, 60)), sf::st_point(c(60, 30)),
sf::st_point(c(150, 50)), sf::st_point(c(320, 50)),
crs = 32630
)
audit_field(eas, gps, size = "households")
#> $areas
#> row field size difference ratio rank flag
#> 1 1 3 4 -1 0.75 2 FALSE
#> 2 2 1 2 -1 0.50 3 FALSE
#> 3 3 0 3 -3 0.00 1 TRUE
#>
#> $outside
#> Simple feature collection with 1 feature and 3 fields
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: 320 ymin: 50 xmax: 320 ymax: 50
#> Projected CRS: WGS 84 / UTM zone 30N
#> point geometry nearest distance
#> 1 5 POINT (320 50) 3 20
#>