50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

cholera (version 0.4.0)

euclideanDistance: Compute the Euclidean distance between cases and/or pumps.

Description

Compute the Euclidean distance between cases and/or pumps.

Usage

euclideanDistance(origin, destination = NULL, type = "case-pump",
  vestry = FALSE, unit = NULL)

Arguments

origin

Numeric or Integer. Numeric ID of case or pump.

destination

Numeric or Integer. Numeric ID(s) of case(s) or pump(s). Exclusion is possible via negative selection (e.g., -7). Default is NULL: this returns closest pump or "anchor" case.

type

Character "case-pump", "cases" or "pumps".

vestry

Logical. TRUE uses the 14 pumps from the Vestry Report. FALSE uses the 13 pumps from the original map.

unit

Character. Unit of measurement: "meter" or "yard". Default is NULL, which returns the map's native scale. See vignette("roads") for information on unit distances.

Value

An R list.

Examples

Run this code
# NOT RUN {
# path from case 1 to nearest pump.
euclideanDistance(1)

# path from case 1 to nearest pump in meters (approximate).
euclideanDistance(1, unit = "meter")

# path from case 1 to pump 6.
euclideanDistance(1, 6)

# exclude pump 7 from consideration.
euclideanDistance(1, -7)

# path from case 1 to case 6.
euclideanDistance(1, 6, type = "cases")

# path from pump 1 to pump 6.
euclideanDistance(1, 6, type = "pumps")

# Plot result
plot(euclideanDistance(1, unit = "meter"))
# }

Run the code above in your browser using DataLab