# Geographic Convert
geo_convert = function(data, lon, lat, geo.in = 31980, geo.out = 4326)
{
f = paste("~", substitute(lon), "+", substitute(lat))
f = stats::as.formula(f)
## convert to sp object
sp::coordinates(data) = f
##
if(is.numeric(geo.in) & is.numeric(geo.out))
{
## adding a coordinate reference system <CRS>: EPSG
sp::proj4string(data) = sp::CRS(paste0("+init=epsg:", geo.in))
##
out = sp::spTransform(data, sp::CRS(paste0("+init=epsg:", geo.out)))
} else if (!is.numeric(geo.in) & !is.numeric(geo.out)) {
## adding a coordinate reference system <CRS>: PROJ4
sp::proj4string(data) = sp::CRS(geo.in)
out = sp::spTransform(data, sp::CRS(geo.out))
} else {
stop("geo.in/geo.out devem ser do mesmo tipo\n EPSG ou Proj4", call. = FALSE)
}#end if
return(out)
}#end function convertUTMtoWGS84
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.