

{"id":3314,"date":"2015-03-15T08:22:10","date_gmt":"2015-03-15T13:22:10","guid":{"rendered":"http:\/\/rud.is\/b\/?p=3314"},"modified":"2018-03-07T16:44:04","modified_gmt":"2018-03-07T21:44:04","slug":"simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/","title":{"rendered":"Simple Lower US 48 Albers Maps &#038; Local (no-API) City\/State Geocoding in R"},"content":{"rendered":"<p>I&#8217;ve been seeing an uptick in static US &#8220;lower 48&#8221; maps with &#8220;meh&#8221; projections this year, possibly caused by a flood of new folks resolving to learn R but using pretty old documentation or tutorials. I&#8217;ve also been seeing an uptick in folks needing to geocode US city\/state to lat\/lon. I thought I&#8217;d tackle both in a quick post to show how to (simply) use a decent projection for lower 48 US maps and then how to use a _very_ basic package I wrote &#8211; [localgeo](http:\/\/github.com\/hrbrmstr\/localgeo) to avoid having to use an external API\/service for basic city\/state geocoding.<\/p>\n<p>### Albers All The Way<\/p>\n<p>I could just plot an Albers projected map, but it&#8217;s more fun to add some data. We&#8217;ll start with some setup libraries and then read in some recent earthquake data, then filter it for our map display:<\/p>\n<pre lang=\"rsplus\">library(ggplot2)\r\nlibrary(dplyr)\r\nlibrary(readr) # devtools::install_github(\"hadley\/readr\")\r\n\r\n# Earthquakes -------------------------------------------------------------\r\n\r\n# get quake data ----------------------------------------------------------\r\nquakes <- read_csv(\"http:\/\/earthquake.usgs.gov\/earthquakes\/feed\/v1.0\/summary\/2.5_month.csv\")\r\n\r\n# filter all but lower 48 US ----------------------------------------------\r\nquakes %>%\r\n  filter(latitude>=24.396308, latitude<=49.384358,\r\n         longitude>=-124.848974, longitude<=-66.885444) -> quakes\r\n\r\n# bin by .5 ---------------------------------------------------------------\r\nquakes$Magnitude <- as.numeric(as.character(cut(quakes$mag, breaks=c(2.5, 3, 3.5, 4, 4.5, 5),\r\n    labels=c(2.5, 3, 3.5, 4, 4.5), include.lowest=TRUE)))<\/pre>\n<p>Many of my mapping posts use quite a few R geo libraries, but this one just needs `ggplot2`. We extract the US map data, turn it into something `ggplot` can work with, then plot our quakes on the map:<\/p>\n<pre lang=\"rsplus\">us <- map_data(\"state\")\r\nus <- fortify(us, region=\"region\")\r\n\r\n# theme_map ---------------------------------------------------------------\r\ndevtools::source_gist(\"33baa3a79c5cfef0f6df\")\r\n\r\n# plot --------------------------------------------------------------------\r\ngg <- ggplot()\r\ngg <- gg + geom_map(data=us, map=us,\r\n                    aes(x=long, y=lat, map_id=region, group=group),\r\n                    fill=\"#ffffff\", color=\"#7f7f7f\", size=0.25)\r\ngg <- gg + geom_point(data=quakes,\r\n                      aes(x=longitude, y=latitude, size=Magnitude),\r\n                      color=\"#cb181d\", alpha=1\/3)\r\ngg <- gg + coord_map(\"albers\", lat0=39, lat1=45)\r\ngg <- gg + theme_map()\r\ngg <- gg + theme(legend.position=\"right\")\r\ngg<\/pre>\n<p><center>2.5+ mag quakes in Lower US 48 in past 30 days<\/center><br \/>\n<center><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3315\" data-permalink=\"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/plot_zoom-4\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png?fit=2038%2C1006&amp;ssl=1\" data-orig-size=\"2038,1006\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Plot_Zoom\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png?fit=510%2C252&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png?resize=510%2C252&#038;ssl=1\" alt=\"Plot_Zoom\" width=\"510\" height=\"252\" class=\"aligncenter size-full wp-image-3315\" \/><\/center><\/p>\n<p>### Local Geocoding<\/p>\n<p>There are many APIs with corresponding R packages\/functions to perform geocoding (one really spiffy recent one is [geocodeHERE](http:\/\/cran.r-project.org\/web\/packages\/geocodeHERE\/)). While Nokia's service is less restrictive than Google's, most of these sites are going to have some kind of restriction on the number of calls per second\/minute\/day. You could always install the [Data Science Toolkit](http:\/\/www.datasciencetoolkit.org\/) locally (note: it was down as of the original posting of this blog) and perform the geocoding locally, but it does take some effort (and space\/memory) to setup and get going.<\/p>\n<p>If you have relatively clean data and only need city\/state resolution, you can use a package I made - [localgeo](http:\/\/github.com\/hrbrmstr\/localgeo) as an alternative. I took a US Gov census shapefile and extracted city, state, lat, lon into a data frame and put a lightweight function shim over it (it's doing nothing more than `dplyr::left_join`). It won't handle nuances like \"St. Paul, MN\" == \"Saint Paul, MN\" and, for now, it requires you to do the city\/state splitting, but I'll be tweaking it over the year to be a bit more forgiving.<\/p>\n<p>We can give this a go and map the [greenest cities in the US in 2014](http:\/\/www.nerdwallet.com\/blog\/cities\/greenest-cities-america\/) as crowned by, er, Nerd Wallet. I went for \"small data file with city\/state in it\", so if you know of a better source I'll gladly use it instead. Nerd Wallet used DataWrapper, so getting the actual data was easy and here's a small example of how to get the file, perform the local geocoding and use an Albers projection for plotting the points. The code below assumes you're still in the R session that used some of the `library` calls earlier in the post.<\/p>\n<pre lang=\"rsplus\">library(httr)\r\nlibrary(localgeo) # devtools::install_github(\"hrbrmstr\/localgeo\")\r\nlibrary(tidyr)\r\n\r\n# greenest cities ---------------------------------------------------------\r\n# via: http:\/\/www.nerdwallet.com\/blog\/cities\/greenest-cities-america\/\r\n\r\nurl <- \"https:\/\/gist.githubusercontent.com\/hrbrmstr\/1078fb798e3ab17556d2\/raw\/53a9af8c4e0e3137a0a8d4d6332f7a6073d93fb5\/greenest.csv\"\r\ngreenest <- read.table(text=content(GET(url), as=\"text\"), sep=\",\", header=TRUE, stringsAsFactors=FALSE)\r\n\r\ngreenest %>%\r\n  separate(City, c(\"city\", \"state\"), sep=\", \") %>%\r\n  filter(!state %in% c(\"AK\", \"HI\")) -> greenest\r\n\r\ngreenest_geo <- geocode(greenest$city, greenest$state)\r\n\r\ngg <- ggplot()\r\ngg <- gg + geom_map(data=us, map=us,\r\n                    aes(x=long, y=lat, map_id=region, group=group),\r\n                    fill=\"#ffffff\", color=\"#7f7f7f\", size=0.25)\r\ngg <- gg + geom_point(data=greenest_geo,\r\n                      aes(x=lon, y=lat),\r\n                      shape=21, color=\"#006d2c\", fill=\"#a1d99b\", size=4)\r\ngg <- gg + coord_map(\"albers\", lat0=39, lat1=45)\r\ngg <- gg + labs(title=\"Greenest Cities\")\r\ngg <- gg + theme_map()\r\ngg <- gg + theme(legend.position=\"right\")\r\ngg<\/pre>\n<p><center>Nerd Wallets's Greenest US (Lower 48) Cities 2014<\/center><br \/>\n<center><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3317\" data-permalink=\"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/plot_zoom-2-3\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom-2.png?fit=1664%2C1050&amp;ssl=1\" data-orig-size=\"1664,1050\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Plot_Zoom 2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom-2.png?fit=510%2C322&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom-2.png?resize=510%2C322&#038;ssl=1\" alt=\"Plot_Zoom 2\" width=\"510\" height=\"322\" class=\"aligncenter size-full wp-image-3317\" \/><\/center><\/p>\n<p>Let me reinforce that the `localgeo` package will most assuredly fail to geocode some city\/state combinations. I'm looking for a more comprehensive shapefile to ensure I have the complete list of cities and I'll be adding some code to help make the lookups more forgiving. It may at least help when you bump into an API limit and need to crank out something in a hurry.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been seeing an uptick in static US &#8220;lower 48&#8221; maps with &#8220;meh&#8221; projections this year, possibly caused by a flood of new folks resolving to learn R but using pretty old documentation or tutorials. I&#8217;ve also been seeing an uptick in folks needing to geocode US city\/state to lat\/lon. I thought I&#8217;d tackle both [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[721,678,673,674,706,91],"tags":[810],"class_list":["post-3314","post","type-post","status-publish","format-standard","hentry","category-cartography","category-data-visualization","category-datavis-2","category-dataviz","category-maps","category-r","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Simple Lower US 48 Albers Maps &amp; Local (no-API) City\/State Geocoding in R - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Simple Lower US 48 Albers Maps &amp; Local (no-API) City\/State Geocoding in R - rud.is\" \/>\n<meta property=\"og:description\" content=\"I&#8217;ve been seeing an uptick in static US &#8220;lower 48&#8221; maps with &#8220;meh&#8221; projections this year, possibly caused by a flood of new folks resolving to learn R but using pretty old documentation or tutorials. I&#8217;ve also been seeing an uptick in folks needing to geocode US city\/state to lat\/lon. I thought I&#8217;d tackle both [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-15T13:22:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-03-07T21:44:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Simple Lower US 48 Albers Maps &#038; Local (no-API) City\\\/State Geocoding in R\",\"datePublished\":\"2015-03-15T13:22:10+00:00\",\"dateModified\":\"2018-03-07T21:44:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/\"},\"wordCount\":602,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Plot_Zoom.png\",\"keywords\":[\"post\"],\"articleSection\":[\"cartography\",\"Data Visualization\",\"DataVis\",\"DataViz\",\"maps\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/\",\"name\":\"Simple Lower US 48 Albers Maps & Local (no-API) City\\\/State Geocoding in R - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Plot_Zoom.png\",\"datePublished\":\"2015-03-15T13:22:10+00:00\",\"dateModified\":\"2018-03-07T21:44:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Plot_Zoom.png?fit=2038%2C1006&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2015\\\/03\\\/Plot_Zoom.png?fit=2038%2C1006&ssl=1\",\"width\":2038,\"height\":1006},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2015\\\/03\\\/15\\\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Simple Lower US 48 Albers Maps &#038; Local (no-API) City\\\/State Geocoding in R\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Simple Lower US 48 Albers Maps & Local (no-API) City\/State Geocoding in R - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/","og_locale":"en_US","og_type":"article","og_title":"Simple Lower US 48 Albers Maps & Local (no-API) City\/State Geocoding in R - rud.is","og_description":"I&#8217;ve been seeing an uptick in static US &#8220;lower 48&#8221; maps with &#8220;meh&#8221; projections this year, possibly caused by a flood of new folks resolving to learn R but using pretty old documentation or tutorials. I&#8217;ve also been seeing an uptick in folks needing to geocode US city\/state to lat\/lon. I thought I&#8217;d tackle both [&hellip;]","og_url":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/","og_site_name":"rud.is","article_published_time":"2015-03-15T13:22:10+00:00","article_modified_time":"2018-03-07T21:44:04+00:00","og_image":[{"url":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png","type":"","width":"","height":""}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Simple Lower US 48 Albers Maps &#038; Local (no-API) City\/State Geocoding in R","datePublished":"2015-03-15T13:22:10+00:00","dateModified":"2018-03-07T21:44:04+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/"},"wordCount":602,"commentCount":2,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png","keywords":["post"],"articleSection":["cartography","Data Visualization","DataVis","DataViz","maps","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/","url":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/","name":"Simple Lower US 48 Albers Maps & Local (no-API) City\/State Geocoding in R - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#primaryimage"},"thumbnailUrl":"https:\/\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png","datePublished":"2015-03-15T13:22:10+00:00","dateModified":"2018-03-07T21:44:04+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png?fit=2038%2C1006&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/03\/Plot_Zoom.png?fit=2038%2C1006&ssl=1","width":2038,"height":1006},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2015\/03\/15\/simple-lower-us-48-albers-maps-local-no-api-citystate-geocoding-in-r\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Simple Lower US 48 Albers Maps &#038; Local (no-API) City\/State Geocoding in R"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p23idr-Rs","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3569,"url":"https:\/\/rud.is\/b\/2015\/07\/29\/introducing-the-nominatim-geocoding-package\/","url_meta":{"origin":3314,"position":0},"title":"Introducing the nominatim geocoding package","author":"hrbrmstr","date":"2015-07-29","format":false,"excerpt":"In the never-ending battle for truth, justice and publishing more R packages than [Oliver](http:\/\/twitter.com\/quominus), I whipped out an R package for the [OpenStreetMap Nominatim API](http:\/\/wiki.openstreetmap.org\/wiki\/Nominatim). It actually hits the [MapQuest Nominatim Servers](http:\/\/open.mapquestapi.com\/nominatim\/) for most of the calls, but the functionality is the same. The R package lets you: - `address_lookup`:\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3538,"url":"https:\/\/rud.is\/b\/2015\/07\/24\/a-path-towards-easier-map-projection-machinations-with-ggplot2\/","url_meta":{"origin":3314,"position":1},"title":"A Path Towards Easier Map Projection Machinations with ggplot2","author":"hrbrmstr","date":"2015-07-24","format":false,"excerpt":"The $DAYJOB doesn't afford much opportunity to work with cartographic datasets, but I really like maps and tinker with shapefiles and geo-data when I can, plus answer a ton of geo-questions on StackOverflow. R makes it easy\u2014one might even say too easy\u2014to work with maps. All it takes to make\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3117,"url":"https:\/\/rud.is\/b\/2014\/11\/16\/moving-the-earth-well-alaska-hawaii-with-r\/","url_meta":{"origin":3314,"position":2},"title":"Moving The Earth (well, Alaska &#038; Hawaii) With R","author":"hrbrmstr","date":"2014-11-16","format":false,"excerpt":"In a previous post we looked at how to use D3 TopoJSON files with R and make some very D3-esque maps. I mentioned that one thing missing was moving Alaska & Hawaii a bit closer to the continental United States and this post shows you how to do that. The\u2026","rel":"","context":"In &quot;d3&quot;","block_context":{"text":"d3","link":"https:\/\/rud.is\/b\/category\/d3\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4217,"url":"https:\/\/rud.is\/b\/2016\/03\/29\/easier-composite-u-s-choropleths-with-albersusa\/","url_meta":{"origin":3314,"position":3},"title":"Easier Composite U.S. Choropleths with albersusa","author":"hrbrmstr","date":"2016-03-29","format":false,"excerpt":"Folks who've been tracking this blog on R-bloggers probably remember [this post](https:\/\/rud.is\/b\/2014\/11\/16\/moving-the-earth-well-alaska-hawaii-with-r\/) where I showed how to create a composite U.S. map with an Albers projection (which is commonly referred to as AlbersUSA these days thanks to D3). I'm not sure why I didn't think of this earlier, but you\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_29_16__9_06_AM.png?fit=1200%2C747&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":11840,"url":"https:\/\/rud.is\/b\/2019\/01\/30\/fast-static-maps-built-with-r\/","url_meta":{"origin":3314,"position":4},"title":"Fast Static Maps Built with R","author":"hrbrmstr","date":"2019-01-30","format":false,"excerpt":"Luke Whyte posted an article (apologies for a Medium link) over on Towards Data Science showing how to use a command line workflow involving curl, node and various D3 libraries and javascript source files to build a series of SVG static maps. It's well written and you should give it\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/01\/fast-static-maps.png?fit=1200%2C806&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/01\/fast-static-maps.png?fit=1200%2C806&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/01\/fast-static-maps.png?fit=1200%2C806&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/01\/fast-static-maps.png?fit=1200%2C806&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/01\/fast-static-maps.png?fit=1200%2C806&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3158,"url":"https:\/\/rud.is\/b\/2014\/12\/29\/making-static-interactive-maps-with-ggvis-using-ggvis-maps-wshiny\/","url_meta":{"origin":3314,"position":5},"title":"Making Static &#038; Interactive Maps With ggvis (+ using ggvis maps w\/shiny)","author":"hrbrmstr","date":"2014-12-29","format":false,"excerpt":"Even though it's still at version `0.4`, the `ggvis` package has quite a bit of functionality and is highly useful for exploratory data analysis (EDA). I wanted to see how geographical visualizations would work under it, so I put together six examples that show how to use various features of\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=3314"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/3314\/revisions"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=3314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=3314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=3314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}