Show information from a dataframe on a shapefile map

5

I have a .dta table that I have already imported for R. One of the columns in this file is called "mun" and it has the municipalities code for Brazil, a 7 digit number.

Idownloadedthe Shapefile from the IBGE website strong> which comes with all files: .cpj , .dbf , .prj , .shp , .shx

I used maptools and I imported the map to R . The map already has the information of the codes of the municipalities like: CD_GEOCMU

require(maptools)
mapa<-readShapeSpatial(file.choose())

My file has more than 4 million data with their respective codes of municipalities. I need to put this data on the map with a color scale so I can see the legal distribution of this data in Brazil, but I have no idea how to do it. Thank you very much if anyone can help me.

    
asked by anonymous 16.12.2016 / 14:58

1 answer

1

I believe the geom_map function of the ggplot2 library is just what you're looking for. It has similar examples in the documentation I linkei. Basically, basically you basically use the fill parameter to define which variable to use to populate the regions.

This article explains step-by-step how to handle data to fit better to ggplot2 logic.

    
17.12.2016 / 01:35