Loading and saving a Shapefile using the SF library
This time we show how to load and save a vector layer file using the new sf library.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 |
library(sf) shp = read_sf("d:/GIS_in_R/powiaty.shp") plot(shp$geometry) shp shp[5,] select = which(shp$jpt_nazwa_ == "powiat pruszkowski") select single_polygon = shp[select,] plot(single_polygon$geometry) write_sf(single_polygon,"d:/GIS_in_R/single_pol.shp") |