I saw a similar question to the one I have in mind, but the solution did not work for me, so I would like to post it here for your help.
I am doing an exercise based on the DataCamp course on geospatial data. Below is the code that I executed as a run:
library(sp)
library(tigris)
nyc_tracts <- tracts(state="NY",county="New York", cb=TRUE)
nyc_tracts is created as a spatial polygon object,
I tried to look at the first polygon in the list with the following syntax:
nyc_tracts@polygons[[1]],
displays the following:
An object of class "Polygons"
Slot "Polygons":
[[1]]
An object of class "Polygon"
Slot "labpt":
[1] -73.98733 40.71516
Slot "area":
[1] 9.884812e-06
Slot "hole":
[1] FALSE
Slot "ringDir":
[1] 1
Slot "coords":
[,1] [,2]
[1,] -73.98975 40.71555
[2,] -73.98915 40.71671
[3,] -73.98837 40.71645
[4,] -73.98672 40.71595
[5,] -73.98501 40.71544
[6,] -73.98426 40.71521
[7,] -73.98334 40.71493
[8,] -73.98245 40.71470
[9,] -73.98471 40.71451
[10,] -73.98534 40.71446
[11,] -73.98716 40.71431
[12,] -73.98934 40.71413
[13,] -73.99022 40.71440
[14,] -73.98975 40.71555
Slot "plotOrder":
[1] 1
Slot "labpt":
[1] -73.98733 40.71516
Slot "ID":
[1] "156"
Slot "area":
[1] 9.884812e-06
Then I tried to display the "area" slot, the "ID" slot and the "plotOrder" slot, etc. with teams like below, and they all worked, for example.
nyc_tracts@polygons[[1]]@area
displayed:
[1] 9.884812e-06
"" (, 14x2, ), , , R :
nyc_tracts@polygons[[1]]@coords
nyc_tracts@polygons[[1]]@coords[1,1]
: "coords" ""
:
coordinates(nyc_tracts)
, ; , , "labpt" 1nyc_tracts, [[1]] ( , 14 ), .
, , . !