R/sendShape.R

#' This function exports a shapefile to a postgreSQL database.
#' @export
#' @title Add a shapefile to a postgreSQL database
#' @name sendShape
#' @param con An object of class "pgConnect" generated by pgConnect()
#' @param folder String with the folder containing the shapefile
#' @param layer A string with the name of shapefile (without the .shp extension)
#' @param pgLayer A string with the name for the layer in the database. Optional
#' @return None
#' @author Bruno Silva
sendShape <- function(con, folder, layer, pgLayer = NULL){
  if(is.null(pgLayer)) pgLayer <- layer
  rgdal::readOGR(folder, layer) %>%
    rgdal::writeOGR(driver = "PostgreSQL",
                    dsn = con[[2]],
                    layer = pgLayer)
}
berdinazzi/easyPostgreSQL documentation built on May 12, 2019, 3:04 p.m.