A few months ago, I did mention that France was a country with strong inequalities, especially when you look at higher education, and research teams. Paris has almost 50% of the CNRS researchers, while only 3% of the population lives there.
CNRS, “répartition des chercheurs en SHS” http://t.co/39dcJJBwrF, Paris 47.52% IdF 66.85% (pop 3.39% et 18.18% resp) pic.twitter.com/OsEXiFywPf
— Arthur Charpentier (@freakonometrics) 28 septembre 2015
It looks like Paris is the only city, in France. And I wanted to check that, indeed, France is a country with strong inequalities, when we look at population density.
Using data from sedac.ciesin.columbia.edu, it is possible to get population density on a small granularity level,
> rm(list=ls()) > base=read.table( + "/home/charpentier/glp00ag.asc", + skip=6) > X=t(as.matrix(base,ncol=8640)) > X=X[,ncol(X):1]
The scales for latitudes and longitudes can be obtained from the text file,
> #ncols 8640 > #nrows 3432 > #xllcorner -180 > #yllcorner -58 > #cellsize 0.0416666666667
Hence, we have
> library(maps) > world=map(database="world") > vx=seq(-180,180,length=nrow(X)+1) > vx=(vx[2:length(vx)]+vx[1:(length(vx)-1)])/2 > vy=seq(-58,85,length=ncol(X)+1) > vy=(vy[2:length(vy)]+vy[1:(length(vy)-1)])/2
If we plot our density, as in a previous post, on Where People Live,
> I=seq(1,nrow(X),by=10) > J=seq(1,ncol(X),by=10) > image(vx[I],vy[J],log(1+X[I,J]), + col=rev(heat.colors(101))) > lines(world[[1]],world[[2]])
we can see that we have a match, between the big population matrix, and polygons of countries.
Consider France, for instance. We can download the contour polygon with higher precision,
> library(rgdal) > fra=download.file( "http://biogeo.ucdavis.edu/data/gadm2.8/rds/FRA_adm0.rds", + "fr.rds") > Fra=readRDS("fr.rds") > n=length([email protected][[1]]@Polygons) > L=rep(NA,n) > for(i in 1:n) L[i]=nrow([email protected][[1]]@Polygons[[i]]@coords) > idx=which.max(L) > polygon_Fr= + [email protected][[1]]@Polygons[[idx]]@coords > min_poly=apply(polygon_Fr,2,min) > max_poly=apply(polygon_Fr,2,max) > idx_i=which((vx>min_poly[1])&(vx> idx_j=which((vy>min_poly[2])&(vy> sub_X=X[idx_i,idx_j] > image(vx[idx_i],vy[idx_j], + log(sub_X+1),col=rev(heat.colors(101)), + xlab="",ylab="") > lines(polygon_Fr)
We are now able to extract information about population for France, only (actually, it is only mainland France, islands are not considered here… to …read more
Source:: r-bloggers.com