I am trying to join .csv file data to shape file data using @data slot. I am getting error

"trying to get slot "polygons" from an object (class "data.frame") that is not an S4 object "

Here is my code:

# reading the data

# converting char to text
Cnty_attrib$Name <- as.character(Cnty_attrib$Name)
KYMap$NAME10 <- as.character(KYMap$NAME10)

# join operation
KYMap<- data.frame(KYMap, Cnty_attrib[match(KYMap[,"NAME10"],Cnty_attrib[,"Name"]),])

head(KYMap@polygons) #to print all the coordinate pairs that make up the objects
  • You seem to confuse sf and sp classes; please read the vignettes of package sf to get up to speed with them. – Edzer Pebesma Jun 23 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.