density_data: Density data

Description Usage Arguments Details Value Examples

Description

Function description process a SpatialPointsDataFrame to give numbers of cases at each unique (x,y) location. Weighting by 1/(local population density) gives corrected numbers which can be used to calculate estimated prevalence.

Usage

1

Arguments

points

SpatialPointsDataFrame containing the line list of patients. Should include: 1) a slot @coords with an n x 2 vector giving the x and y coordinates of each case. (More than one case can have the same co-ordinates.) 2) a slot @bbox giving the maximum and minimum x and y co-ordinates.

weights

If required, the local population density at each (x, y) coordinate.

Details

Process a SpatialPointsDataFrame to give numbers of cases at each unique (x,y) location. Weighting by 1/(local population density) gives corrected numbers which can be used to calculate estimated prevalence.

Value

A data frame containing x and y co-ordinates, and (weighted) counts. For use by other functions including estimate_density.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if(require(sp)){
# simulate a line list of patient locations
my.linelist <- data.frame(	longitude = round(runif(100, 0, 10), 0.01),
								latitude = round(runif(100, 0, 10), 0.01)
							)
#transform patients dataframe into spatialpointsdataframe
pointspatients <- SpatialPointsDataFrame(my.linelist, data=data.frame(id=1:100))

my.density.data <- density_data(pointspatients)
print(head( my.density.data ))
}

Hackout2/mapData documentation built on May 6, 2019, 9:48 p.m.