#' Project for web function
#'
#' This function allows you to reproject spatial data to WGS84, which is the projection required for webmaps such as leaflet.js
#'
#' You can either use the default WGS84 projection or supply your own.
#'
#' @param dat Expects input of sp object: point, polygon, etc.
#' @param projection Defaults to WGS84
#' @keywords ggplot NZ maps
#' @examples
#' webprojected <- proj4web(anyprojection)
#' @import rgdal
#' @import sp
#' @import mapproj
#' @export
proj4web <- function(dat, projection = '+proj=longlat +datum=WGS84'){
require(sp)
spTransform(dat, CRS(projection))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.