This function computes data to match a grid layer (as outputed by getGridLayer ) according to the surface intersections.
getGridData(x, df, dfid = NULL, var)
A data frame is returned. id_cell are ids of the grid, the two other variable are the share of the variable in each cell and the share of the variable in each cell divided by its area (in map units).
## Not run: ------------------------------------ # data(nuts2006) # # Create a grid layer # mygrid <- getGridLayer(spdf=nuts2.spdf,cellsize = 200000) # # Compute data for the grid layer # datagrid.df <- getGridData(mygrid, nuts2.df, "pop2008",dfid=NULL) # # # Plot total population # plot(mygrid$spdf, col="#CCCCCC",border="white") # propSymbolsLayer(spdf = mygrid$spdf, df = datagrid.df, legend.style = "e", # legend.pos = "right", border = "white",legend.title.txt = "Total population", # var = "pop2008", inches=0.01, col="black", add=TRUE) # # # Plot dentsity of population # ## conversion from square meter to square kilometers # datagrid.df$densitykm <- datagrid.df$pop2008_density*1000*1000 # cols <- carto.pal(pal1 = "taupe.pal", n1 = 6) # choroLayer(spdf = mygrid$spdf,df = datagrid.df,var = "densitykm", add=FALSE, # border = "grey80",col=cols, # legend.pos = "right", method = "q6", # legend.title.txt = "Population density") # ## ---------------------------------------------