Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Loading Multiple Shapefiles to the R Console Simultaneously

DZone's Guide to

Loading Multiple Shapefiles to the R Console Simultaneously

· Big Data Zone
Free Resource

See how the beta release of Kubernetes on DC/OS 1.10 delivers the most robust platform for building & operating data-intensive, containerized apps. Register now for tech preview.

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


New Mesosphere DC/OS 1.10: Production-proven reliability, security & scalability for fast-data, modern apps. Register now for a live demo.

Topics:

Published at DZone with permission of Kay Cichini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}