[GIS] Change Circle Size According to Value using R

cartographypopulationr

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. Messy California population map

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.

Best Answer

Thanks to Curlew, I was able to solve my question. I dropped the color distinctions, to allow for publication on a b/w environment. Here is what I have done:

## I added a new column with logarithmic data ##
pop[,4]<-log(pop[,1])

## I changed my mind and decided to work still with non-logarithmic data ##
map(database='state',regions=c("California"),col="black", lwd=.3, resolution=.1)
points(pop$LONG, pop$LAT, pch=21, bg=24, cex=pop$POP10/50000, lwd=.4)

And here is my result:

California grey balloons

Three more questions (not sure if it is appropriate to ask further questions here, though):

  • is it ok to work with non-logarithmic data?

  • how do I know what values to add in the legend?

  • is there a way to plot city names only for the main cities? I know I should include those in the matrix first; after that, how do I do that? And most of all, is that recommendable in such a messy map like this one?