0

This question already has an answer here:

I have loaded the sp library in R and the rds file for a specific country (see here), now how can I extract the list of coordinates from this object?

When I ask for the names of the object, the result is:

 [1] "OBJECTID"      "ID_0"          "ISO"           "NAME_ENGLISH"  "NAME_ISO"     
 [6] "NAME_FAO"      "NAME_LOCAL"    "NAME_OBSOLETE" "NAME_VARIANTS" "NAME_NONLATIN"
[11] "NAME_FRENCH"   "NAME_SPANISH"  "NAME_RUSSIAN"  "NAME_ARABIC"   "NAME_CHINESE" 
[16] "WASPARTOF"     "CONTAINS"      "SOVEREIGN"     "ISO2"          "WWW"          
[21] "FIPS"          "ISON"          "VALIDFR"       "VALIDTO"       "POP2000"      
[26] "SQKM"          "POPSQKM"       "UNREGION1"     "UNREGION2"     "DEVELOPING"   
[31] "CIS"           "Transition"    "OECD"          "WBREGION"      "WBINCOME"     
[36] "WBDEBT"        "WBOTHER"       "CEEAC"         "CEMAC"         "CEPLG"        
[41] "COMESA"        "EAC"           "ECOWAS"        "IGAD"          "IOC"          
[46] "MRU"           "SACU"          "UEMOA"         "UMA"           "PALOP"        
[51] "PARTA"         "CACM"          "EurAsEC"       "Agadir"        "SAARC"        
[56] "ASEAN"         "NAFTA"         "GCC"           "CSN"           "CARICOM"      
[61] "EU"            "CAN"           "ACP"           "Landlocked"    "AOSIS"        
[66] "SIDS"          "Islands"       "LDC"  

Am I wrong to assume the list is among one of these?

marked as duplicate by Spacedman, tinlyx, Vince, xunilk, fdetsch Mar 26 '18 at 6:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

Sp spatial classes store information in slots, which have the prefix @. Coordinates should be inside the @coords slot for each polygon.

But if you are not familiar with sp class structures it is better to use the sf package, which uses simple geometries.

1) You can convert your sp object to an sf class:
New<-st_as_sf(Old)

2) You can retrieve the coordinates with: CoordNew<-st_coordinates(New)

CoordNew is a matrix of x,y coordinates

Not the answer you're looking for? Browse other questions tagged or ask your own question.