1 Star 6 Fork 9

RStata 团队 / stata-highmaps

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.Rmd 2.89 KB
一键复制 编辑 原始数据 按行查看 历史
Painter 提交于 2020-12-01 21:16 . submit
output
github_document
# 使用 Stata 绘制全世界所有国家以及部分国家的区划地图数据 这里存放了使用 Stata 绘制全世界所有国家以及部分国家的区划地图数据,geojson 数据爬取自:https://img.hcharts.cn/mapdata 。 欢迎大家关注微信公众号“RStata” 和 “Stata 中文社区” 获取最新资讯和动态! RStata | Stata中文社区 :-:|:-: | ## 使用示例 例如对于 [欧洲](https://czxa.github.io/code-data-zip/%E6%AC%A7%E6%B4%B2.zip),下载解压之后会得到下面这些文件: + europe(文件夹) + europe_coord.dta + europe_db.dta + europe_line_coord.dta + europe_line_db.dta + europe.geo.json + europe.png + europe地图绘制方法.do 其中 europe.geo.json 文件是从 https://img.hcharts.cn/mapdata 爬取到的原始数据,dta 文件是转换后得到的 Stata 地图数据文件,europe(文件夹)里面装的是 shp 文件。europe.png 是使用 Stata 绘制的结果,`europe地图绘制方法.do` 是绘图的示例代码: ```stata * europe 地图绘制方法: * 欢迎关注微信公众号 RStata 获取更多 Stata 相关的学习资料和资源! * 作者:微信 r_stata * 注意:运行代码前请记得把工作目录设置为 europe_db.dta 文件所在的文件夹。 use "europe_db", clear gen value = int(runiform(1, 84)) spmap value using europe_coord, id(ID) /// fcolor("252 255 164" "252 181 25" "237 105 37" "187 55 84" /// "120 28 109" "51 10 95") /// ocolor("black" ...) /// clmethod(custom) clbreaks(0 14 28 42 56 70 84) /// graphr(margin(medlarge)) /// caption("绘制:微信公众号 RStata", size(*0.8)) /// osize(vvthin ...) /// legend(size(*1.3) /// order(2 "0~14" 3 "14~28" 4 "28~42" 5 "42~56" 6 "56~70" 7 "70~84") /// ti(示例数据, size(*0.5) pos(11) color(black)) color(black)) /// label(data(europe_db) x(x_centroid) y(y_centroid) l(name) color(gs10) size(*0.8 ...)) /// line(data(europe_coord) size(*0.2 ...) color(black)) gr export "europe.png", replace ``` ![](https://mdniceczx.oss-cn-beijing.aliyuncs.com/image_20201124114414.png) ## 下载数据 ```{r echo=FALSE, warning=FALSE} library(tidyverse) library(fs) dir_ls('code-data-zip') %>% as.character() %>% str_remove("code-data-zip/") %>% str_remove(".zip") %>% as_tibble() %>% mutate(下载链接 = paste0("https://r-stata.github.io/stata-highmaps/code-data-zip/", value, ".zip")) %>% mutate(下载链接 = paste0("", value, "")) %>% rename(`国家/地区` = value) %>% knitr::kable() ``` ------------

License

MIT © tidyfriday.cn
1
https://gitee.com/tidyfriday/stata-highmaps.git
git@gitee.com:tidyfriday/stata-highmaps.git
tidyfriday
stata-highmaps
stata-highmaps
main

搜索帮助

53164aa7 5694891 3bd8fe86 5694891