Public Resources

Useful R codes for big data analysis

1. Multiple layers from a geodatabase (gdb)

# 1. Load multiple layers from a geodatabase (e.g. plantations_v1_3_dl.gdb, downloadable from

# 2. Merge all layers into one spatial dataframe

# 3. Write the merge file into a shapefile.

# Developed by Jingjing Liang @7/17/2020. This script comes with absolutely no warranty. Use at your own risk.


layers <- st_layers(“C:/mydirectory/plantations_v1_3_dl.gdb”)
layers <- layers$name

shp1 <- sf::st_read(dsn = “C:/mydirectory/plantations_v1_3_dl.gdb”, layer=layers[1])

for (i in 2:length(layers)){
shp <- sf::st_read(dsn = “C:/mydirectory/plantations_v1_3_dl.gdb”, layer=layers[i])
shp1 <- rbind(shp1,shp)

st_write(shp1, dsn=paste0(“C:/mydirectory/plantaions_v1_3_shp/”, “plantation_merged.shp”),driver = “ESRI Shapefile”)

Leave a Reply