epikml: Plot geocoded cases in a KML file

View source: R/epikml.R

epikmlR Documentation

Plot geocoded cases in a KML file

Description

epikml() takes a set of coordinates and other associated info as input, and creates a KML (Keyhole Markup Language) file that can be opened with Google Earth or other similar programs. It's original intention was to plot disease cases, but can find wider use as well.

Usage

epikml(
  x,
  y,
  by = NA,
  name = NA,
  info = NA,
  labelinfo = NA,
  pin = "default",
  pin.type = NULL,
  file = NA
)

Arguments

x

A numeric vector of longitudes

y

A numeric vector of latitudes

by

A factor, or a list of factors (each of the same length as x and y) that are used to group each case in the KML file.

name

A vector (of same length as x and y) with names for each case. These are printed next to each pin.

info

A vector, or a list of vectors (each of the same length as x and y) with extra information about each case. These will be displayed in the pop-up frame that appears when one clicks on a pin, in a simple tabular format.

labelinfo

A vector of length one or more (equal to the number of vectors in argument info), with corresponding labels for each type of information.

pin

A character vector with the color and style for each pin, or a factor whose levels correspond to the pin.type argument, which in that case will be a vector of pin colors and styles. See "Details".

pin.type

A character vector (of same length as x and y) of pin colors and styles, which correspond to the factor levels of the argument pin. If NA, then the argument pin holds the color and style of each pin.

file

A file name to output the KML into. Otherwise the KML is printed on the screen.

Details

The following pin styles are recognized: pushpin, paddle, blank, circle, diamond, square, stars. Also the following pin colors: blue, green, yellow, white, light blue, pink, purple, red. Pin color precedes pin style, e.g. "blue pushpin", "green diamond", etc. Alternatively, capital english letters and numbers from 1 to 10 can be specified; these create a red paddle pin with the respective letter or number in its centre.

Value

Nothing. The function prints its output on the screen or on a KML file.

Examples

# Create some dummy data
dat <- data.frame(
   lon = c(23.7, 23.8, 23.75, 23.78),
   lat = c(38.1, 38, 38.02, 38.07),
   nom = c("Case A", "Case B", "Case C", "Case D"),
   gender = c("Male", "Male", "Female", "Female"),
   died = c(TRUE, FALSE, FALSE, FALSE)
)
with(dat, epikml(lon, lat, by = gender, name = nom, 
   info = list(gender, died), labelinfo=c("Gender", "Died?"),
   pin = died, pin.type=c("green paddle", "purple paddle"), 
   file="diseaseCases.kml"))
# File 'diseaseCases.kml' will be in your working directory.
# Open it with Google Earth or a similar program.


thlytras/Rivets documentation built on April 16, 2024, 5:43 a.m.