R/expshape.R

#' expshape
#' 
#' @description
#' Should not be called directly by users.
#' \code{expshape} exports shapefiles of lines and buffers.
#'
#' @param x List with data, spatial lines and polygons generated by \code{area_calc}.
#' @param c_epsg EPSG code for projected buffers.
#'
#' @return Exports shapefiles.
#' @export
#'
#' @examples
#' \dontrun{
#' }
expshape <- function(x, c_epsg = 3395){
  require(sp)
  require(rgdal)
  mycrs <- paste("+init=epsg:", c_epsg,sep="")
#7.3 write shape

  mypn <- as.character(x$SpatialLines_proj$SpatialLinesAll$plot_id[1]) 
  linename <- paste(mypn, "_linha.shp", sep="")

  require(raster)
  raster::shapefile(x$SpatialLines_proj$SpatialLinesAll, 
            filename = linename)

#names(list_res$"M02_TN_1500"$SpatialLines_proj) # export "SpatialLinesAll"
#names(list_res$"M02_TN_1500"$"buff_SpatialLinesAll")
#[1] "buf_0.5m" "buf_10m"  "buf_12m"  "buf_1m"   "buf_20m"  "buf_21m"  "buf_22m"  "buf_3m"  
#class(list_res$"M02_TN_1500"$"buff_SpatialLinesAll"$buf_0.5m)

# exemplos write shapefile
#library(raster)
#export linha central como shapefile

#list_res$'M01_TN_0500'$SpatialLines_wgs84$SpatialLinesAll@data
# export buffer como shapefile 
# need to convert to "SpatialPolygonsDataFrame"
#mydata <- data.frame(id = getSpPPolygonsIDSlots(
#  (list_res$'M01_TN_0500'$buff_SpatialLinesAll$buf_10m)))
#rownames(mydata) <- mydata$id
#spdf <- SpatialPolygonsDataFrame( 
#  list_res$'M01_TN_0500'$buff_SpatialLinesAll$buf_10m, data= mydata)
#shapefile(spdf, filename ='MO1_TN_0500_10.shp')
#  sppoint <- df_tracks_out2[, c('aname', 'trip_id', 'trip_start','zone','gpstime', 'adtAP',
#                                'ayear', 'adate', 'ele','lon', 'lat', 'bear_deg_clean',
#                                'vel', 'dist_m_clean', 'dist_m_census')]
#  sp::coordinates(sppoint) <- ~lon+lat
#  sp::proj4string(sppoint) <- sp::CRS("+init=epsg:4326")
#  namepoint <- paste(paste("trackpoints", fileend, sep="_"),".shp",sep="")
#  raster::shapefile(sppoint, filename = namepoint)
}
darrennorris/parcelareadev documentation built on May 14, 2019, 6:11 p.m.