[R] Removing polygons from shapefile of Scotland and Islands
Nick Wray
n|ckmwr@y @end|ng |rom gm@||@com
Tue May 14 15:16:23 CEST 2024
Hello I have a shapefile of Scotland, including the islands. The river
flow data I am using is only for the mainland and for a clearer and larger
map I would like to not plot Orkney and Shetland to the north of the
mainland, as I don't need them.
The map I have I got from
https://borders.ukdataservice.ac.uk/easy_download_data.html?data=infuse_ctry_2011
then I put the uk shapefile onto my laptop with no problems (I have sf
running)
the_uk<-st_read(dsn="C:/Users/nickm/Desktop/Shapefiles/infuse_ctry_2011.shp")
scotland<-the_uk[2,]
plot(scotland$geometry)
This gives me a nice map of Scotland plus islands but obviously there are
lots of separate polygons and if I go into the points with something like
scot_pts<-unlist(as.data.frame(scotland$geometry))
it's not at all clear how I can get rid of the points I don't want as they
don't seem to be listed in any easy way to find where one polygon stops and
another starts
I am wondering whether this approach is right anyway or whether there is
some sf function which would allow me to identify the polygons I want -
essentially the big one which is the mainland without lots of elaborate
conversions and manipulations
Any pointers, thoughts etc much appreciated
Thanks Nick Wray
[[alternative HTML version deleted]]
More information about the R-help
mailing list