Dot Density Maps in R
city = readShapePoly("/home/xuefliang/RInMedicine/city/city_region.shp")
gpclibPermit() #install.packages("gpclib", type = "source")
tract <- fortify(city,region="CNTY_CODE")
city@data$USE_CODE8 <- sample(1000,14)
dots.rand <- dotsInPolys(city, as.integer(city@data$USE_CODE8))
#table(iconv(city$NAME, from = "GBK"))
dots <- data.frame(coordinates(dots.rand)[,1:2])
ggplot(tract, aes(x = long, y = lat)) +
geom_polygon(aes(group = group), size=0.2, fill = "white") +
coord_equal()+geom_point(data=dots, aes(x=x,y=y), size=0.8,colour="red")
gpclibPermit() #install.packages("gpclib", type = "source")
tract <- fortify(city,region="CNTY_CODE")
city@data$USE_CODE8 <- sample(1000,14)
dots.rand <- dotsInPolys(city, as.integer(city@data$USE_CODE8))
#table(iconv(city$NAME, from = "GBK"))
dots <- data.frame(coordinates(dots.rand)[,1:2])
ggplot(tract, aes(x = long, y = lat)) +
geom_polygon(aes(group = group), size=0.2, fill = "white") +
coord_equal()+geom_point(data=dots, aes(x=x,y=y), size=0.8,colour="red")
评论
发表评论