Learn R Programming

SDLfilter (version 2.3.1)

to_kmz: Generate KMZ from locations and track

Description

Function to generate a kmz file from tracking data. This is a wrapper of kml, specifically designed to generate a kmz file from tracking data.

Usage

to_kmz(sdata, crs = 4326, file.name = "id", ...)

Value

A kmz file

Arguments

sdata

A data frame containing location data of one individual, with the following column headers: "id", "DateTime", "lat", "lon". "id" is an identifier of the individual. "DateTime" is the GMT date & time of each location in class POSIXct or character with the following format "2012-06-03 01:33:46". "lat" and "lon" are the latitude and longitude of each location in decimal degrees.

crs

A number specifying the European Petroleum Survey Group (EPSG) code for the input location data.

file.name

A character specifying the output file name.

...

Optional arguments passed to kml_layer for points.

Author

Takahiro Shimada

See Also

map_track

Examples

Run this code
## Tracking data of two green turtles
data(turtle); data(turtle2)

## Filter data
d1 <- ddfilter(dupfilter(turtle))
d2 <- ddfilter(dupfilter(turtle2))

## Combine two data
d <- list(d1, d2) 

if (FALSE) {
## Generate a kmz file from each tracking data
shp <- 'http://maps.google.com/mapfiles/kml/pal2/icon18.png'
for(i in 1:2){
  # labels for points (date and time)
  pn <- d[[i]]$DateTime
  
  # Apply a colour gradient to points based on the date and time
  pt_col <- hcl.colors(n = nrow(d[[i]]), palette = 'Zissou 1')
 
  # Generate a kmz file
  to_kmz(d[[i]], shape = shp, colour_scale = pt_col, colour = pn, points_names = pn, LabelScale = 0)
 }
}

Run the code above in your browser using DataLab