R/add_buffer.R

Defines functions add_buffer

add_buffer=function(Input,buf=NA,SeparateBuf=TRUE){

  buf=buf*1852
  Shp=st_buffer(x=Input,dist=buf)
  
  if(SeparateBuf==FALSE){
    Shp=st_union(Shp)
    Shp=st_set_geometry(x=data.frame(ID=1), Shp)
    }
  if("AreaKm2"%in%colnames(Shp)){
    colnames(Shp)[which(colnames(Shp)=="AreaKm2")]="Unbuffered_AreaKm2"
  }
  #Get buffered areas
  Ar=round(st_area(Shp)/1000000,1)
  Shp$Buffered_AreaKm2=as.numeric(Ar)
  return(Shp)
}

Try the CCAMLRGIS package in your browser

Any scripts or data that you put into this service are public.

CCAMLRGIS documentation built on Sept. 27, 2023, 9:09 a.m.