{"id":16571507,"url":"https://github.com/hrbrmstr/ggcounty","last_synced_at":"2025-03-21T12:30:58.261Z","repository":{"id":16116692,"uuid":"18861846","full_name":"hrbrmstr/ggcounty","owner":"hrbrmstr","description":":globe_with_meridians: Generate ggplot2 geom_map county maps","archived":false,"fork":false,"pushed_at":"2017-12-09T04:12:18.000Z","size":2800,"stargazers_count":63,"open_issues_count":5,"forks_count":10,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-18T01:11:16.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"R","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/hrbrmstr.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}},"created_at":"2014-04-17T00:50:00.000Z","updated_at":"2024-07-27T22:17:20.000Z","dependencies_parsed_at":"2022-09-18T08:54:01.986Z","dependency_job_id":null,"html_url":"https://github.com/hrbrmstr/ggcounty","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/hrbrmstr%2Fggcounty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fggcounty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fggcounty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hrbrmstr%2Fggcounty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hrbrmstr","download_url":"https://codeload.github.com/hrbrmstr/ggcounty/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244799236,"owners_count":20512212,"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":[],"created_at":"2024-10-11T21:24:12.448Z","updated_at":"2025-03-21T12:30:57.692Z","avatar_url":"https://github.com/hrbrmstr.png","language":"R","funding_links":[],"categories":["Spatial"],"sub_categories":[],"readme":"ggcounty\n========\n\nGenerate `ggplot2` `geom_map` United States county maps\n\nThis is a simple package with two purposes:\n\n- make it easier to generate US County maps (willing to do others if pointed to good shapefiles) with ggplot2 \u0026 geom_map\n- use more up-to-date shapefiles than what's in the `maps` package (I mean, it *still* uses \"USSR\" for Russia :-)\n\nAs some folks have pointed out (and, one main reason I issued the request-for-comments at such an early stage) is that I wanted to gauge the desire for a more `geom`-oriented/generic way to do county-level mapping than the `#spiffy` [choroplethr](http://cran.r-project.org/web/packages/choroplethr/index.html) package.\n\nAfter installation, just do:\n\n    library(devtools)\n    install_github(\"hrbrmstr/ggcounty\")\n    library(ggcounty)\n\n    maine \u003c- ggcounty(\"Maine\")\n    maine$gg\n    \nTo get:\n\n![map](https://rawgit.com/hrbrmstr/ggcounty/master/maine.svg)\n\nThe `maine` object in the above code contains\n\n- the `gg` ggplot2 object\n- a `map` object which is a \"fortified\" data frame\n- a `county.names` object which is a list of all county names (or FIPS codes) in that county\n- a `geom_map` object (`geom`) for the state county map\n\nHere is an example of the structure (truncated for brevity):\n\n    \u003e str(maine)\n    List of 4\n     $ map         :'data.frame':\t724 obs. of  7 variables:\n      ..$ long : num [1:724] -70 -70 -70 -70 -70 ...\n      ..$ lat  : num [1:724] 44.1 44.1 44 44 44 ...\n      ..$ order: int [1:724] 1 2 3 4 5 6 7 8 9 10 ...\n      ..$ hole : logi [1:724] FALSE FALSE FALSE FALSE FALSE FALSE ...\n      ..$ piece: Factor w/ 2 levels \"1\",\"2\": 1 1 1 1 1 1 1 1 1 1 ...\n      ..$ group: Factor w/ 18 levels \"Androscoggin.1\",..: 1 1 1 1 1 1 1 1 1 1 ...\n      ..$ id   : chr [1:724] \"Androscoggin\" \"Androscoggin\" \"Androscoggin\" \"Androscoggin\" ...\n     $ county.names: chr [1:16] \"Androscoggin\" \"Aroostook\" \"Cumberland\" \"Franklin\" ...\n     $ gg          :List of 9\n      ..$ data       : list()\n      .. ..- attr(*, \"class\")= chr \"waiver\"\n      ..$ layers     :List of 1\n      .. ..$ :Classes 'proto', 'environment' \u003cenvironment: 0x7f8cbe7292d8\u003e \n      ..$ scales     :Reference class 'Scales' [package \"ggplot2\"] with 1 fields\n      .. ..$ scales: list()\n      .. ..and 21 methods, of which 9 are possibly relevant:\n      .. ..  add, clone, find, get_scales, has_scale, initialize, input, n, non_position_scales\n      ..$ mapping    : list()\n      ..$ theme      :List of 7\n      .. ..$ plot.background :List of 4\n      .. .. ..$ fill    : chr \"transparent\"\n      .. .. ..$ colour  : logi NA\n      .. .. ..$ size    : NULL\n      .. .. ..$ linetype: NULL\n      .. .. ..- attr(*, \"class\")= chr [1:2] \"element_rect\" \"element\"\n      .. ..$ panel.border    : list()\n      .. .. ..- attr(*, \"class\")= chr [1:2] \"element_blank\" \"element\"\n      .. ..$ panel.background:List of 4\n      .. .. ..$ fill    : chr \"transparent\"\n      .. .. ..$ colour  : logi NA\n      .. .. ..$ size    : NULL\n      .. .. ..$ linetype: NULL\n      .. .. ..- attr(*, \"class\")= chr [1:2] \"element_rect\" \"element\"\n      .. ..$ panel.grid      : list()\n      .. .. ..- attr(*, \"class\")= chr [1:2] \"element_blank\" \"element\"\n      .. ..$ axis.text       : list()\n      .. .. ..- attr(*, \"class\")= chr [1:2] \"element_blank\" \"element\"\n      .. ..$ axis.ticks      : list()\n      .. .. ..- attr(*, \"class\")= chr [1:2] \"element_blank\" \"element\"\n      .. ..$ legend.position : chr \"right\"\n      .. ..- attr(*, \"class\")= chr [1:2] \"theme\" \"gg\"\n      .. ..- attr(*, \"complete\")= logi FALSE\n      ..$ coordinates:List of 4\n      .. ..$ projection : chr \"mercator\"\n      .. ..$ orientation: NULL\n      .. ..$ limits     :List of 2\n      .. .. ..$ x: NULL\n      .. .. ..$ y: NULL\n      .. ..$ params     : list()\n      .. ..- attr(*, \"class\")= chr [1:2] \"map\" \"coord\"\n      ..$ facet      :List of 1\n      .. ..$ shrink: logi TRUE\n      .. ..- attr(*, \"class\")= chr [1:2] \"null\" \"facet\"\n      ..$ plot_env   :\u003cenvironment: R_GlobalEnv\u003e \n      ..$ labels     :List of 3\n      .. ..$ x     : chr \"\"\n      .. ..$ y     : chr \"\"\n      .. ..$ map_id: chr \"id\"\n      ..- attr(*, \"class\")= chr [1:2] \"gg\" \"ggplot\"\n     $ geom        :Classes 'proto', 'environment' \u003cenvironment: 0x7f8cbf7b5f58\u003e \n     \nThis lets you add further map layers (e.g. for a choropleth):\n\n    library(ggcounty)\n    \n    # built-in US population by FIPS code data set\n    data(population)\n    \n    # define appropriate (\u0026 nicely labeled) population breaks\n    population$brk \u003c- cut(population$count, \n                          breaks=c(0, 100, 1000, 10000, 100000, 1000000, 10000000), \n                          labels=c(\"0-99\", \"100-1K\", \"1K-10K\", \"10K-100K\", \n                                   \"100K-1M\", \"1M-10M\"),\n                          include.lowest=TRUE)\n    \n    # get the US counties map (lower 48)\n    us \u003c- ggcounty.us()\n    \n    # start the plot with our base map\n    gg \u003c- us$g\n    \n    # add a new geom with our population (choropleth)\n    gg \u003c- gg + geom_map(data=population, map=us$map,\n                        aes(map_id=FIPS, fill=brk), \n                        color=\"white\", size=0.125)\n    \n    # define nice colors\n    gg \u003c- gg + scale_fill_manual(values=c(\"#ffffcc\", \"#c7e9b4\", \"#7fcdbb\", \n                                          \"#41b6c4\", \"#2c7fb8\", \"#253494\"), \n                                 name=\"Population\")\n    \n    # plot the map\n    gg\n\n![map2](https://rawgit.com/hrbrmstr/ggcounty/master/mainechoro.png)\n\nAnd, combining individual maps is pretty straightforward:\n\n    ny \u003c- ggcounty(\"New York\", fill=\"#c7e9b4\", color=\"white\")\n    nj \u003c- ggcounty(\"New Jersey\", fill=\"#41b6c4\", color=\"white\")\n    pa \u003c- ggcounty(\"Pennsylvania\", fill=\"#253494\", color=\"white\")\n\n    ny$gg + nj$geom + pa$geom \n    \n\n![map2](https://rawgit.com/hrbrmstr/ggcounty/master/tristate.png)\n\nor have the county names/FIPS codes as a quick reference or for verifitcation.\n\n    \u003e ny$county.names\n     [1] \"Albany\"       \"Allegany\"     \"Bronx\"        \"Broome\"       \"Cattaraugus\"  \"Cayuga\"      \n     [7] \"Chautauqua\"   \"Chemung\"      \"Chenango\"     \"Clinton\"      \"Columbia\"     \"Cortland\"    \n    [13] \"Delaware\"     \"Dutchess\"     \"Erie\"         \"Essex\"        \"Franklin\"     \"Fulton\"      \n    [19] \"Genesee\"      \"Greene\"       \"Hamilton\"     \"Herkimer\"     \"Jefferson\"    \"Kings\"       \n    [25] \"Lewis\"        \"Livingston\"   \"Madison\"      \"Monroe\"       \"Montgomery\"   \"Nassau\"      \n    [31] \"New York\"     \"Niagara\"      \"Oneida\"       \"Onondaga\"     \"Ontario\"      \"Orange\"      \n    [37] \"Orleans\"      \"Oswego\"       \"Otsego\"       \"Putnam\"       \"Queens\"       \"Rensselaer\"  \n    [43] \"Richmond\"     \"Rockland\"     \"Saratoga\"     \"Schenectady\"  \"Schoharie\"    \"Schuyler\"    \n    [49] \"Seneca\"       \"St. Lawrence\" \"Steuben\"      \"Suffolk\"      \"Sullivan\"     \"Tioga\"       \n    [55] \"Tompkins\"     \"Ulster\"       \"Warren\"       \"Washington\"   \"Wayne\"        \"Westchester\" \n    [61] \"Wyoming\"      \"Yates\"  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fggcounty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhrbrmstr%2Fggcounty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhrbrmstr%2Fggcounty/lists"}