Skip to content

Instantly share code, notes, and snippets.

@ZeccaLehn
Last active September 25, 2017 23:19
Show Gist options
  • Save ZeccaLehn/3da83ca94309e88ec0babe7707fc3e04 to your computer and use it in GitHub Desktop.
Save ZeccaLehn/3da83ca94309e88ec0babe7707fc3e04 to your computer and use it in GitHub Desktop.
Census & Money 2017 Top 100 Places (Fips/Zips/Lat/Long/County/State)

Code to download attached csv and clean leading zeros, if needed

http://time.com/money/collection/best-places-to-live-2017/

library(data.table)
library(RCurl)
dest <- "https://gist.githubusercontent.com/ZeccaLehn/3da83ca94309e88ec0babe7707fc3e04/raw/81f0ee0cea8097cbdaaf980be6d0eda2bb10b3a4/Final_Money_100.csv"
dataRaw <- getURL(dest, ssl.verifypeer=FALSE)
dataRaw <- as.data.table(read.csv(text = dataRaw, sep = ",", stringsAsFactors = F))
head(dataRaw)

  # # Pads leading zeros for state fips
  # dataRaw$stateFips <- sprintf("%02d",dataRaw$stateFips)
  # # Pads leading zeros for county fips
  # dataRaw$countyFips <- sprintf("%03d",dataRaw$countyFips)
  # # Pads leading zeros for place fips
  # dataRaw$placeFips <- sprintf("%05d",dataRaw$placeFips)

Plot 100 places on US Map

library(ggmap)
map <- get_map(location = 'USA', zoom = 4)
ggmap(map) +
  geom_point(aes(x = longitude, y = latitude), size = 5, 
             data = dataRaw, alpha = .5) 
place stateAbbr Rank county state stateFips countyFips placeFips censusPlaceType placeSym zip latitude longitude
Fishers IN 1 Hamilton INDIANA 18 57 23278 Incorporated Place A 46037 39.96 -85.94
Allen TX 2 Collin TEXAS 48 85 1924 Incorporated Place A 75002 33.092846 -96.62447
Monterey Park CA 3 Los Angeles CALIFORNIA 6 37 48914 Incorporated Place A 91754 34.048207 -118.14161
Franklin TN 4 Williamson TENNESSEE 47 187 27740 Incorporated Place A 37064 35.893823 -86.89919
Olive Branch MS 5 DeSoto MISSISSIPPI 28 33 54040 Incorporated Place A 38654 34.954106 -89.83743
Dickenson ND 6 Stark NORTH DAKOTA 38 89 19620 Unknown Unknown 58601 46.879176 -102.789624
Lone Tree CO 7 Douglas COLORADO 8 35 45955 Incorporated Place A 80130 39.541571 -104.92152
North Arlington NJ 8 Bergen NEW JERSEY 34 3 52320 Unknown Unknown 7031 40.791895 -74.13254
Schaumburg IL 9 Cook ILLINOIS 17 31 68003 Unknown Unknown 60159 41.811929 -87.68732
Bozeman MT 10 Gallatin MONTANA 30 31 8950 Incorporated Place A 59715 45.707153 -110.9878
New Berlin WI 11 Waukesha WISCONSIN 55 133 56375 County Subdivision F 53146 42.973663 -88.15414
Beaverton OR 12 Washington OREGON 41 67 5350 Incorporated Place A 97005 45.49106 -122.80359
Waltham MA 13 Middlesex MASSACHUSETTS 25 17 72600 County Subdivision F 2154 42.388938 -71.2398
Orem UT 14 Utah UTAH 49 49 57300 Incorporated Place A 84057 40.311854 -111.70561
Saint Peters MO 15 St. Charles MISSOURI 29 183 65126 Unknown Unknown 63376 38.778579 -90.62045
Carmel IN 16 Hamilton INDIANA 18 57 10342 Incorporated Place A 46032 39.970241 -86.15416
Avon IN 17 Hendricks INDIANA 18 63 2908 Incorporated Place A 46123 39.764436 -86.39699
Santa Monica CA 18 Los Angeles CALIFORNIA 6 37 70000 Incorporated Place A 90401 34.01491 -118.4922
Grapevine TX 19 Tarrant TEXAS 48 439 30644 Incorporated Place A 76051 32.93195 -97.08498
Wylie TX 20 Collin TEXAS 48 85 80356 Incorporated Place A 75098 33.011975 -96.53607
Brentwood TN 21 Williamson TENNESSEE 47 187 8280 Incorporated Place A 37024 35.874553 -86.907565
Greenwood IN 22 Johnson INDIANA 18 81 29898 Incorporated Place A 46142 39.62068 -86.15126
Bedford TX 23 Tarrant TEXAS 48 439 7132 Incorporated Place A 76021 32.851678 -97.13849
Saddle Brooke NJ 24 Bergen NEW JERSEY 34 3 65340 Unknown Unknown 7663 40.904009 -74.100732
Bismark ND 25 Burleigh NORTH DAKOTA 38 15 7200 Unknown Unknown 58501 46.829487 -100.768696
Newton MA 26 Middlesex MASSACHUSETTS 25 17 45560 County Subdivision F 2158 42.353696 -71.188149
Wheaton IL 27 DuPage ILLINOIS 17 43 81048 Incorporated Place A 60187 41.858279 -88.10904
Villa Park IL 28 DuPage ILLINOIS 17 43 77993 Unknown Unknown 60181 41.880429 -87.97813
Reston VA 29 Fairfax VIRGINIA 51 59 66672 Census Designated Place S 20190 38.959673 -77.3462
Ashburn VA 30 Loudoun VIRGINIA 51 107 3320 Census Designated Place S 20146 39.085309 -77.645224
Smyrna TN 31 Rutherford TENNESSEE 47 149 69420 Incorporated Place A 37167 35.968513 -86.52231
Fond Du Lac WI 32 Fond Du Lac WISCONSIN 55 39 26275 Unknown Unknown 54935 43.769889 -88.4281
Parsippany NJ 33 Morris NEW JERSEY 34 27 56460 Unknown Unknown 7054 40.860149 -74.4171
Lebenon TN 34 Wilson TENNESSEE 47 189 41520 Unknown Unknown 37087 36.20811 -86.291102
Des Plaines IL 35 Cook ILLINOIS 17 31 19642 Incorporated Place A 60016 42.047178 -87.89058
Clifton NJ 36 Passaic NEW JERSEY 34 31 13690 County Subdivision F 7011 40.879699 -74.14263
Wooster OH 37 Wayne OHIO 39 169 86548 Incorporated Place A 44691 40.800086 -81.95726
Concord NC 38 Cabarrus NORTH CAROLINA 37 25 14100 Incorporated Place A 28025 35.400407 -80.56574
Rockville MD 39 Montgomery MARYLAND 24 31 67675 Incorporated Place A 20847 39.143979 -77.207617
Howard WI 40 Chippewa WISCONSIN 55 17 36000 County Subdivision A 54313 44.562353 -88.080305
Mequon WI 41 Ozaukee WISCONSIN 55 89 51150 County Subdivision F 53097 43.234506 -88.00914
O'Fallon MO 42 St. Charles MISSOURI 29 183 54074 Incorporated Place A 63366 38.810608 -90.699848
Fayetteville AR 43 Washington ARKANSAS 5 143 23290 Incorporated Place A 72701 36.040467 -94.13376
Bend OR 44 Deschutes OREGON 41 17 5800 Incorporated Place A 97701 44.091256 -121.29769
Rogers AR 45 Benton ARKANSAS 5 7 60410 Incorporated Place A 72756 36.342235 -94.07141
Lower Merion PA 46 Montgomery PENNSYLVANIA 42 91 44976 Unknown Unknown 19003 40.024967 -75.282905
Midlothian VA 47 Chesterfield VIRGINIA 51 41 51560 Unknown Unknown 23113 37.506107 -77.649
Meridian ID 48 Ada IDAHO 16 1 52120 Incorporated Place A 83642 43.609434 -116.39642
Superior CO 49 Jefferson COLORADO 8 59 75640 Incorporated Place A 80027 39.952763 -105.168598
Lousville CO 50 Boulder COLORADO 8 13 46355 Unknown Unknown 80027 39.977763 -105.13193
Farmington Hills MI 51 Oakland MICHIGAN 26 125 27440 County Subdivision F 55121 42.498994 -83.367717
Sandy UT 52 Salt Lake UTAH 49 35 67440 Incorporated Place A 84070 40.581595 -111.88821
Broomfield CO 53 Broomfield COLORADO 8 14 9280 Incorporated Place A 80020 39.93404 -105.05454
Rochester Hills MI 54 Oakland MICHIGAN 26 125 69035 County Subdivision F 48306 42.658366 -83.149932
Hernando MS 55 DeSoto MISSISSIPPI 28 33 31780 Incorporated Place A 38632 34.811777 -90.01917
West Chester OH 56 Butler OHIO 39 17 58149 Unknown Unknown 45069 39.343757 -84.40249
Nashua NH 57 Hillsborough NEW HAMPSHIRE 33 11 50260 County Subdivision F 3030 42.749988 -71.46431
Springdale AR 58 Washington ARKANSAS 5 143 66080 Incorporated Place A 72762 36.186059 -94.1937
Lenexa KS 59 Johnson KANSAS 20 91 39350 Incorporated Place A 66200 38.953617 -94.733571
Los Alamitos CA 60 Orange CALIFORNIA 6 59 43224 Incorporated Place A 90720 33.794028 -118.07218
Eagan MN 61 Dakota MINNESOTA 27 37 17288 County Subdivision F 52001 44.804132 -93.166886
Saint Augustine FL 62 St. Johns FLORIDA 12 109 62500 Unknown Unknown 32084 29.87131 -81.29464
Ellicot City MD 63 Howard MARYLAND 24 27 26000 Unknown Unknown 21041 39.267328 -76.798307
Council Bluffs IA 64 Pottawattamie IOWA 19 155 16860 Incorporated Place A 51501 41.251631 -95.87447
Papillion NE 65 Sarpy NEBRASKA 31 153 38295 Incorporated Place A 68046 41.151899 -96.04484
Powell OH 66 Delaware OHIO 39 41 64486 Incorporated Place A 43065 40.155515 -83.08415
Woodbury MN 67 Washington MINNESOTA 27 163 71428 County Subdivision F 55125 44.923855 -92.95938
Siloam Springs AR 68 Benton ARKANSAS 5 7 64370 Incorporated Place A 72761 36.179905 -94.50208
La Vista NE 69 Sarpy NEBRASKA 31 153 26385 Incorporated Place A 68128 41.183458 -96.05318
Shawnee KS 70 Johnson KANSAS 20 91 64500 Incorporated Place A 66203 39.022848 -94.715187
Delaware OH 71 Delaware OHIO 39 41 21434 Incorporated Place A 43015 40.295925 -83.06968
West Goshen PA 72 Chester PENNSYLVANIA 42 29 83080 Unknown Unknown 19380 39.979041 75.591709
Weymouth Town MA 73 Norfolk MASSACHUSETTS 25 21 78972 County Subdivision F 2188 42.218072 -70.941036
Lehi UT 74 Utah UTAH 49 49 44320 Incorporated Place A 84043 40.366648 -111.89052
North Liberty IA 75 Johnson IOWA 19 103 57360 Incorporated Place A 52317 41.755771 -91.61238
Knightdale NC 76 Wake NORTH CAROLINA 37 183 36080 Incorporated Place A 27545 35.790516 -78.48345
Dubuque IA 77 Dubuque IOWA 19 61 22395 Incorporated Place A 52001 42.515252 -90.6794
Norwood MA 78 Norfolk MASSACHUSETTS 25 21 50250 County Subdivision A 2062 42.185974 -71.20166
Vinings GA 79 Cobb GEORGIA 13 67 79612 Census Designated Place S 30339 33.864826 -84.464374
Paradise Valley AZ 80 Maricopa ARIZONA 4 13 52930 Incorporated Place A 85253 33.544596 -111.95645
Williston ND 81 Williams NORTH DAKOTA 38 105 86220 Incorporated Place A 58801 48.20496 -103.71908
Salem NH 82 Rockingham NEW HAMPSHIRE 33 15 66660 County Subdivision A 3079 42.792456 -71.21316
East Norriton PA 83 Montgomery PENNSYLVANIA 42 91 21600 Unknown Unknown 19403 40.151774 -75.336569
Burnsville MN 84 Dakota MINNESOTA 27 37 8794 County Subdivision F 55306 44.732569 -93.28909
Minnetonka MN 85 Hennepin MINNESOTA 27 53 43252 County Subdivision F 55345 44.915413 -93.48443
Colchester VT 86 Chittenden VERMONT 50 7 14875 County Subdivision A 5439 44.49518 -73.165092
Urbandale IA 87 Polk IOWA 19 153 79950 Incorporated Place A 50322 41.630521 -93.7238
Mustang OK 88 Canadian OKLAHOMA 40 17 50100 Incorporated Place A 73064 35.388059 -97.73626
Mercer Island WA 89 King WASHINGTON 53 33 45005 Incorporated Place A 98040 47.569271 -122.23233
Morrisville NC 90 Wake NORTH CAROLINA 37 183 44520 Incorporated Place A 27560 35.846363 -78.83866
Newcastle WA 91 King WASHINGTON 53 33 48645 Incorporated Place A 98056 47.538989 -122.155677
Lee's Summit MO 92 Jackson MISSOURI 29 95 41348 Incorporated Place A 64015 38.910841 -94.382172
Mauldin SC 93 Greenville SOUTH CAROLINA 45 45 45115 Incorporated Place A 29662 34.774657 -82.30432
Cedar Mill OR 94 Washington OREGON 41 67 97229 Census Designated Place S 97229 45.527734 -122.80467
Helena MT 95 Lewis and Clark MONTANA 30 49 35600 Incorporated Place A 59601 46.588803 -112.04193
North Salt Lake UT 96 Davis UTAH 49 11 55210 Incorporated Place A 84054 40.843012 -111.90581
Nixa MO 97 Christian MISSOURI 29 43 52616 Incorporated Place A 65714 37.045593 -93.30563
Pelham AL 98 Shelby ALABAMA 1 117 58848 Incorporated Place A 35124 33.317471 -86.78726
Rapid City SD 99 Pennington SOUTH DAKOTA 46 103 52980 Incorporated Place A 57700 44.090788 -103.284511
South Portland ME 100 Cumberland MAINE 23 5 71990 County Subdivision F 4106 43.631549 -70.27272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment