#' raster to polygon
#'
#' @param raster
#' @param shp
#'
#' @return
#' @export
#'
#' @examples
#' rlog = system.file("pictures/Rlogo.jpg",package = "rgdal")
#' shpR = "D:/shp_export"
#' system.time(raster2polygon(rlog,shp))
raster2polygon <- function(ras,shp){
r1 <- raster::brick(ras)
poly1 <- rasterToPolygons(r1, dissolve = T)
dirr=dirname(shp)
shpName = basename(shp)
writeOGR(obj=poly1, dsn=dirr, layer=shpName, driver="ESRI Shapefile")
}
#' array to raster
#'
#' @param ar
#'
#' @return
#' @export
#'
#' @examples
array2raster <- function(ar)
{
data(rgdal::Rlogo)
b <- brick(Rlogo)
plotRGB(b,stretch='lin',asp=1 ,axes=T, main="Original")
}
#' get_tif
#'
#' @return
#' @export
#'
#' @examples
get_tif <- function(){
rlog <- system.file("pictures/Rlogo.jpg",package = "rgdal")
rb <- raster::brick(rlog)
return(rb)
}
#' Title
#'
#' @return
#' @export
#'
#' @examples
get_jpg <- function(){
rlog = system.file("pictures/Rlogo.jpg",package = "rgdal")
rb = raster::brick(rlog)
return(rb)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.