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")

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理