The way I did this recently is to look into the .dbf file that comes with the shapefile group from ESRI or your feature site, and search the feature names for the one I want. This gives you an index to use to search for the feature in the actual shapefile. Then, once the shapefile is loaded into R using the shapefiles package, you can get the vectors of polygon vertices by
lr <- shapefiles::read.shapefile(myFile) # lr is the shapefile object sfs <- lr$shp[myIndex] #sfs will be a list and the first element is the geometry sfp <- sfs[[1]]$points #sfp is the set of X and Y vertices lines(sfp$X],sfp$Y,col='red',lwd=2) David David K Stevens, PhD, PE, Professor Civil and Environmental Engineering Utah Water Research Laboratory Utah State University 8200 Old Main Hill Logan, UT 84322-8200 david.stev...@usu.edu (435) 797-3229 (office) On 10/21/2022 12:01 PM, Jeff Newmiller wrote: > As the Posting Guide would have warned you, you will probably have better > luck asking this kind of question on the R-sig-geo mailing list. > > On October 21, 2022 10:45:30 AM PDT, Nick Wray <nickmw...@gmail.com> wrote: >> Hello I have downloaded a large shapefile dataset of UK rivers and I want >> to isolate (as an ordinary R string) the LINESTRING values for particular >> lines, corresponding to rivers >> Looking at the first line I can isolate the geometry by >> >> Hello I have downloaded a large shapefile dataset of UK rivers and I want >> to isolate (as an ordinary R string) the LINESTRING values for particular >> lines, corresponding to rivers >> >> Looking at the first line I can isolate the geometry by >> >> >> >> st_geometry(rivers[1,8]) >> >> >> >> Geometry set for 1 feature >> Geometry type: LINESTRING >> Dimension: XYZ >> Bounding box: xmin: 462010.6 ymin: 1213039 xmax: 462306.5 ymax: 1213199 >> z_range: zmin: 0 zmax: 0 >> Projected CRS: OSGB 1936 / British National Grid >> >> LINESTRING Z (462306.5 1213048 0, 462275.4 1213... >> >> >> What I need is all the values in the LINESTRING as a common or garden R >> vector, but I cannot find a way to do this. >> >> Does anyone know how? Thanks, Nick Wray >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. > -- > Sent from my phone. Please excuse my brevity. > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > CAUTION: This email originated from outside of USU. If this appears to be a > USU employee, beware of impersonators. Do not click links, reply, download > images, or open attachments unless you verify the sender’s identity and know > the content is safe. > ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.