#' Get the Center of a Bunch of Polygons
#'
#' @param polygons a SpatialPolygonsDataFrame
#'
#' @return a two column data frame with the longitude and latitude of the center point of polygons
#' @export
#'
getcenterofpolygons <- function(polygons) {
blob <- rgeos::gUnaryUnion(polygons)
center <- blob@polygons[[1]]@labpt
dplyr::data_frame(lon = center[1], lat = center[2])
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.