encodeCoordinates {googlePolylines}R Documentation

Encode coordinates

Description

Encodes a vector of lon & lat coordinates

Usage

encodeCoordinates(lon, lat)

Arguments

lon

vector of longitudes

lat

vector of latitudes

See Also

encode

Examples

## Not run: 

## Grouping by polygons and lines
df <- data.frame(polygonId = c(1,1,1,1,1,1,1,1,2,2,2,2),
  lineId = c(1,1,1,1,2,2,2,2,1,1,1,1),
  lon = c(-80.190, -66.118, -64.757, -80.190,  -70.579, -67.514, -66.668, -70.579, 
  -70, -49, -51, -70),
  lat = c(26.774, 18.466, 32.321, 26.774, 28.745, 29.570, 27.339, 28.745, 
  22, 23, 22, 22))


## using dplyr groups   

library(dplyr)
df %>%
  group_by(polygonId, lineId) %>% 
  summarise(polyline = encodeCoordinates(lon, lat))
  
## using data.table
library(data.table)
setDT(df)
df[, encodeCoordinates(lon = lon, lat = lat), by = .(polygonId, lineId)]



## End(Not run)


[Package googlePolylines version 0.8.4 Index]