{"word_count": 101, "character_count": 1107}
There was an interesting map on reddit this morning, with a visualisation of latitude and longituge of where people live, on Earth. So I tried to reproduce it. To compute the density, I used a kernel based approch&#62; library(maps)&#62; data("world.cities")&#62; X=world.cities[,c("lat","pop")]&#62; liss=function(x,h){+   w=dnorm(x-X[,"lat"],0,h)+   sum(X[,"pop"]*w)+ }&#62; vx=seq(-80,80)&#62; vy=Vectorize(function(x) liss(x,1))(vx)&#62; vy=vy/max(vy)&#62; plot(world.cities$lon,world.cities$lat,)&#62; for(i in 1:length(vx)) + abline(h=vx[i],col=rgb(1,0,0,vy[i]),lwd=2.7)For the other axis, we use a miror technique, to ensure that -180 is close the +180&#62; Y=world.cities[,c("long","pop")]&#62; Ya=Y; Ya[,1]=Y[,1]-360&#62; Yb=Y; Yb[,1]=Y[,1]+360&#62; Y=rbind(Y,Ya,Yb)&#62; liss=function(y,h){+   w=dnorm(y-Y[,"long"],0,h)+   sum(Y[,"pop"]*w)+ } &#62; vx=seq(-180,180)&#62; vy=Vectorize(function(x) liss(x,1))(vx)&#62; vy=vy/max(vy)&#62; plot(world.cities$lon,world.cities$lat,pch=19)&#62; for(i in 1:length(vx)) + abline(v=vx[i],col=rgb(1,0,0,vy[i]),lwd=2.7)Now we can add the two, on the same graph