It would be better to ask this question on r-sig-geo. More people there are more familiar with the structure of Spatial{*} classes.
-Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 4/8/15, 2:07 PM, "Monica Pisica" <pisican...@hotmail.com> wrote: > >Hi, > > > >I am struggling to extract the polygon vertices from a list of an object >class "Polygons", specifically the slot "coords". > > > > I have a point, and i "draw" a buffer around with gBuffer, i am >"extracting" the polygon form the SpatialPolygons class and i end up with >a list of 1 one object Polygons class that seems to have slots, but if i >try to extract them i get an error. > > > >So here it goes after i load the respective libraries: sp, maptools, >rgdal, rgeos > >pt1 <- data.frame(x=217680.2, y = 3817555) > >coordinates(pt1) <- c("x", "y") > >crs = "+proj=utm +zone=11 +datum=NAD83 +units=m +no_defs +ellps=GRS80 >+towgs84=0,0,0" > > > >proj4string(pt1) <- CRS(crs) > >pt1.cpoly <- gBuffer(pt1, width = 100, byid = TRUE) > > > >pt1.cpoly > >class : SpatialPolygons > >features : 1 > >extent : 217580.2, 217780.2, 3817455, 3817655 (xmin, xmax, ymin, >ymax) > >coord. ref. : +proj=utm +zone=11 +datum=NAD83 +units=m +no_defs >+ellps=GRS80 +towgs84=0,0,0 > > > >pt1.poly <- pt1.cpoly@polygons > > > >pt1.poly > >[[1]] > >An object of class "Polygons" > >Slot "Polygons": > >[[1]] > >An object of class "Polygon" > >Slot "labpt": > >[1] 217680.2 3817554.7 > > > >Slot "area": > >[1] 30901.7 > > > >Slot "hole": > >[1] FALSE > > > >Slot "ringDir": > >[1] 1 > > > >Slot "coords": > > x y > > [1,] 217780.2 3817555 > > [2,] 217775.3 3817524 > > [3,] 217761.1 3817496 > > [4,] 217739.0 3817474 > >Etc. Š.. > > > >pt1.crd <- pt1.poly[[1]]@coords > >Error: no slot of name "coords" for this object of class "Polygons" > > > >So my question is: How do i access the "coords" slot i clearly see when i >print pt1.poly on the screen? > > > >Thanks for any help, > > > >Monica >______________________________________________ >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. ______________________________________________ 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.