encodeCoordinates | R Documentation |
Encodes a vector of lon & lat coordinates
encodeCoordinates(lon, lat)
lon |
vector of longitudes |
lat |
vector of latitudes |
encode
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.