Show information of a dataframe on a shapefile map

Asked

Viewed 126 times

5

I have a table. dta that I already imported into the R. One of the columns of this file is called "Mun" and has the code of the municipalities of Brazil, a number of 7 digits. inserir a descrição da imagem aqui

I lowered the Shapefile of the website of IBGE that comes all files: .cpj, .dbf, .prj, .shp, .shx

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

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

My file has over 4 million data with their respective county codes. I need to put this data on the map with a color scale to be able to see the distribution of this data in Brazil legally, but I have no idea how to do that. I really appreciate it if someone can help me.

1 answer

1

I believe the function geom_map, library ggplot2, is just what you are looking for. There are similar examples in the documentation that Inkei. Roughly speaking, basically you use the parameter fill to define which variable to use to populate regions.

This article explains step-by-step how to treat the data in a way that is better suited to the logic of ggplot2.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.