GISR

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:

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")

Leave a Reply

Your email address will not be published. Required fields are marked *