Big Data/Analytics Zone is brought to you in partnership with:

Kay Cichini (MSc, Biology), Nature Protection Expert, Tyrol/Austria. I'm author of theBioBucket-Blog, where I share examples for data management, data processing, statistical analysis and report generation using the R-Software. Kay is a DZone MVB and is not an employee of DZone and has posted 28 posts at DZone. You can read more from them at their website. View Full User Profile

Loading Multiple Shapefiles to the R Console Simultaneously

09.30.2013
| 895 views |
  • submit to reddit

Here is a quick tip on how to load multiple shapefiles (i.e., point shapefiles) to the R console in one go:

library(maptools)
 
# get all files with the .shp extension from working directory
setwd("D:/GIS_DataBase/GIS_Tirol/Tirol_Verbreitungskarten/Verbreitungs_Daten")
 
shps <- dir(getwd(), "*.shp")
 
# the assign function will take the string representing shp and turn it into a variable
# which holds the spatial points data
for (shp in shps) assign(shp, readShapePoints(shp))
plot(get(shp[1])) # i.e.
# ...done


Published at DZone with permission of Kay Cichini, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)