Last active
December 12, 2015 12:19
-
-
Save gka/4770983 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(plotrix) | |
library(shapefiles) | |
library(proj4) | |
par(mar=c(0,0,0,0), oma=c(0,0,0,0)) | |
LAEA <- "+proj=laea +lat_0=52 +lon_0=10 +x_0=4321000 +y_0=3210000 +ellps=GRS80 +units=m +no_defs" | |
shp <- read.shp("vg2500_bld.shp") # read shapefile | |
simple <- convert.to.simple(shp)[, -1] # read states | |
simple <- project(simple, proj=LAEA) # project to LAEA | |
cities = read.csv("cc.csv", stringsAsFactors=F) | |
xy <- project(list(as.numeric(cities$lon), as.numeric(cities$lat)), proj=LAEA) | |
cities$X <- xy$x | |
cities$Y <- xy$y | |
symbols(cities$X, cities$Y, circles=sqrt(cities$matches.total), xlab="", ylab="", axes=F, bg=rgb(0,0,0,0.3), fg=rgb(0,0,0,0.5), asp=T) # plot city circles | |
points(simple, cex=0.1, pch=20, col=rgb(0,0,0,.4)) # plot states | |
big <- cities[which(cities$matches.total > 600), ] # filter biggest cities for label display | |
thigmophobe.labels(big$X, big$Y, big$name, col='darkred', cex=(big$matches.total / max(big$matches.total))^0.8 * 3+0.5, font=2) # plot city names | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment