GADMTools (version 3.8-1)

gadm_sf_import_shp: read and import a file in shapefile format

Description

read and import a file in shapefile format (.shp,.dbf,.proj) and put it in gadm_sf format for use with GADMTools

Usage

gadm_sf_import_shp(dir, name, level, del = NULL, 
                     renamed = NULL, keepall = FALSE)

Arguments

dir

Character path to the directory where .shp file is located (eg. <U+201C>./<U+201D>)

name

Character name of the .shp file without the extension (example: <U+201C>india<U+201D>)

level

Integer the administrative level

del

Character vector the variables (columns) to be deleted (optional if keepall == FALSE)

renamed

Character vector the variables to be renamed (eg. the administrative fields in GADM are named NAME_X where X is the level, and the ISO code(3))

keepall

Boolean if FALSE (default), allows to keep only the columns useful for GADMTools

Value

Object of class gadm_sf (Simple Features wrapper)

References

----

Examples

Run this code
# NOT RUN {
# library(GADMTools)
# map <- gadm_sf_import_shp(dir="./", name = "india", level = 2,
#                           del = c("DCODE", "NAME3", "SDCODE"),
#                           renamed = c(<U+2019>ISO<U+2019> = <U+2019>COUNTRY<U+2019>,
#                                       <U+2019>NAME_0<U+2019> = <U+2019>COUNTRY_LO<U+2019>,
#                                       <U+2019>NAME_1<U+2019> = <U+2019>NAME1<U+2019>,
#                                       <U+2019>NAME_2<U+2019> = <U+2019>NAME2<U+2019>),
#                           keepall = FALSE
#                          )
# map$sf$ISO <- "IND"
# map$sf$NAME_0 <- "India"
# }

Run the code above in your browser using DataLab