{"id":18704892,"url":"https://github.com/xiaohk/ggplot2-china-map","last_synced_at":"2025-04-12T10:04:37.281Z","repository":{"id":134719703,"uuid":"120217584","full_name":"xiaohk/ggplot2-china-map","owner":"xiaohk","description":"Use ggplot2 to plot China map, and provide a JSON file of coordinates of major Chinese cities","archived":false,"fork":false,"pushed_at":"2018-02-05T04:53:36.000Z","size":2546,"stargazers_count":28,"open_issues_count":1,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T10:02:15.696Z","etag":null,"topics":["china-city","china-map","ggplot2","jupyter-notebook","map","r"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xiaohk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-02-04T19:51:54.000Z","updated_at":"2024-12-24T10:57:29.000Z","dependencies_parsed_at":"2023-03-17T02:11:55.046Z","dependency_job_id":null,"html_url":"https://github.com/xiaohk/ggplot2-china-map","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohk%2Fggplot2-china-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohk%2Fggplot2-china-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohk%2Fggplot2-china-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xiaohk%2Fggplot2-china-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xiaohk","download_url":"https://codeload.github.com/xiaohk/ggplot2-china-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550634,"owners_count":21122933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["china-city","china-map","ggplot2","jupyter-notebook","map","r"],"created_at":"2024-11-07T12:09:00.716Z","updated_at":"2025-04-12T10:04:37.276Z","avatar_url":"https://github.com/xiaohk.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# China Map with ggplot2\nThis project demonstrates how to use `ggplot2` to plot a non-built-in map using the shapefile.\n\n## Plot the map\nThe plot process is fairly straightforward. We can load the shapefile (in `china_shapefile`) using `readOGR()`. Then we fortify it to a normal dataframe. We can modify the dataframe if needed. For this project I ignored islands in the South China Sea, since there are no students on the list from there. Next, we use `geom_polygon` layer to plot the map, and add `coord_map` to make it looks pretty. Finally we can add other standard data layer onto the map, using the geometrical coordinates as aesthetic mapping. \n\nThe process is done in `plot_china.r`.\n\n[\u003cimg src=\"./plot1.svg\" width=\"400\"\u003e](./plot1.svg)[\u003cimg src=\"./plot2.svg\" width=\"400\"\u003e](./plot2.svg)\n\n## Data Processing\n\nFor this specific project, data are parsed from the [UW-Madison’s Dean’s List of 2017 Spring](https://dataviz.wisc.edu/views/UW-MadisonDeansList/ListDashboard?:iid=1\u0026:isGuestRedirectFromVizportal=y\u0026:embed=y). My data include all students from mainland China, Hong Kong and Taiwan. The cleaned file is stored as `deanlist_2017_fall.csv`, and the cleaning process is in `data_cleaning.ipynb`.\n\n## China city coordinates\nTo plot the cities on the map, I parsed a simple JSON file of Chinese city coordinates. \n\nThis JSON file includes over 300 major cities in China. The main key is the English name of one, and value is another dictionary containing its Chinese name and coordinates (latitude, longitude). \n\n```javascript\n{\n\t\"kelamayi\": {\n\t\t\"coord\": [\n\t\t\t45.5943,\n\t\t\t84.8812\n\t\t],\n\t\t\"hanzi\": \"克拉玛依市\"\n\t},\n\t\"kezileisu\": {\n\t\t\"coord\": [\n\t\t\t39.7503,\n\t\t\t76.1376\n\t\t],\n\t\t\"hanzi\": \"克孜勒苏柯尔克孜自治州\"\n\t},\n\t\"kunming\": {\n\t\t\"coord\": [\n\t\t\t25.0492,\n\t\t\t102.7146\n\t\t],\n\t\t\"hanzi\": \"昆明市\"\n\t}\n}\n```\n\nTo make the JSON file more generic, I also added some alias of keys. For example, `xianggang` and `hongkong`, `xian` and `xi'an`, `kelamayi` and `karamay`, etc.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaohk%2Fggplot2-china-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxiaohk%2Fggplot2-china-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxiaohk%2Fggplot2-china-map/lists"}