Skip to contents

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.

Usage

audit_field(x, points, size = NULL, weight = NULL, flag = 0.5)

Arguments

x

An sf object of the frame's areas, in a projected CRS.

points

An sf or sfc of field points in the CRS of x.

size

The estimated size of each area, as a column name of x or a numeric vector, or NULL (default) to report field counts only.

weight

The count each point stands for, such as households in a structure, as a column name of points or a numeric vector, or NULL (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.5 flags 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 of x, holding row and field (the weight of its points). With size, it also holds size, difference (field minus size), ratio (field over size, NA for an estimate of 0), rank (1 for the largest absolute difference) and flag.

  • outside, an sf object of the points in no area, with point (their row in points), nearest (the row of the nearest area) and distance.

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

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
#>