How do I change circle size in a population map according to the population density of the location?
library(maptools)
library(RColorBrewer)
library(classInt)
library(maps)
## load the file ##
pop <- read.table("[pop.txt][1]", header=TRUE, row.names=1, sep=",")
## select color palette and the number colors to represent on the map ##
colors <- brewer.pal(9, "YlOrRd")
#set breaks for the 9 colors
brks<<-classIntervals(pop$POP10, n=9, style="quantile")
brks<- brks$brks
map(database='state',regions=c("California"),col="black", lwd=.3, resolution=.1)
points(pop$LONG, pop$LAT, pch=21, bg=colors, cex=0.7, lwd=.4)
This way I obtain a map like this.
I would like to create a map that shows very small dots for little population density (lighter points in the example) and bigger dots as the population density increases.
points(pop$LONG, pop$LAT, pch=21, bg=colors, cex=pop$POP10, lwd=.4)
pop$newPop <- log(pop$POP10)
). Depending on your data this might or might not work. If it doesn't think about creating an quantile interval like you did for the colors and assign it to your population data (match
).