Developing Geographic Thematic Maps with R

前端 未结 6 779
终归单人心
终归单人心 2020-12-04 04:34

There are clearly a number of packages in R for all sorts of spatial analysis. That can by seen in the CRAN Task View: Analysis of Spatial Data. These packages are numerous

6条回答
  •  旧巷少年郎
    2020-12-04 05:20

    It is just three lines!

    library(maps);
    colors = floor(runif(63)*657);
    map("state", col = colors, fill = T, resolution = 0)
    

    Done!! Just change the second line to any vector of 63 elements (each element between 0 and 657, which are members of colors())

    Now if you want to get fancy you can write:

    library(maps);
    library(mapproj);
    colors = floor(runif(63)*657);
    map("state", col = colors, fill = T, projection = "polyconic", resolution = 0);
    

    The 63 elements represent the 63 regions whose names you can get by running:

    map("state")$names;
    

提交回复
热议问题