I have a SpatialLinesDataFrame (Shapefiles) with 115 features. I am trying to figure out, if it is possible, to write some sort loop that would enable me to select and save out each of the features individually with file names that would be referenced in one of the columns.
For example, I have a trail.shp file with 115 different trails that I would like to subset into 115 individual trail.shp files, based on the names of the trails.
I know how to do it individually, the example below uses my real data:
sanitasvalley<- subset(boulder_trails, TRAILNAME == "Sanitas Valley")
But I hope that I can make this process more efficient with a coding solution instead of having to go one-by-one.
Here is a general example of my data.
trailname <- ("trail1", "trail2", "trail3") trailtype <- ("mountain", "flat", "hilly") parking <- ("no", "yes", "no") trails <- data.frame(accessname, trailtype, parking)
I would like to select each trail, and save it out as the name that appears under the "trail name" column i.e., trail1.shp
Thanks for looking