How keep information from shapefile after fortify()

后端 未结 4 931
萌比男神i
萌比男神i 2021-02-05 10:06

How can I keep polygons\'s information after shapefile? Let me try to explain:

I have a shapefile with this data:

> head(mapa@data)
         ID      C         


        
4条回答
  •  没有蜡笔的小新
    2021-02-05 10:26

    Maybe this is a slightly simpler solution

    library(dplyr)
    library(ggplot2)
    
    # fortify the shape file
      map.df <- fortify(shape, region ="CD_GEOCODI")
    
    # merge data
      map.df <- left_join(map.df, data, by=c('id'='CD_GEOCODI'))
    

提交回复
热议问题