R/readDivaGis.R

Defines functions readDivaGis

Documented in readDivaGis

#' Read DIVA GIS country boundaries and converts it so that there is only one
#' feature per country and has an ISO3 name.
#' 
#' Reads DIVA GIS country boundaries as polygons from disk.
#' 
#' 
#' @usage readDivaGis()
#' @return Country polygons with ISO3 names
#' @author Ulrich Kreidenweis
#' @examples
#' 
#' \dontrun{readDivaGis()}
#' 
#' @export readDivaGis
#' @importFrom rgdal readOGR
readDivaGis <- function() {
  
  boundaries <- readOGR("DIVA GIS/countries_shp/countries.shp", layer="countries")
  ISO3 <- as.character(boundaries$ISO3)
  
  # there are several polygons some countries, these are dissolved to multipolygons 
  boundariesU <- maptools::unionSpatialPolygons(boundaries, ISO3)
  
  return(boundariesU)
}
pik-piam/geodata documentation built on Nov. 5, 2019, 12:21 a.m.