3

I have a list of lat and long for several thousand members and want to append their census tract block group code(i.e. 36001038141345). My first thought is to plot these members on a map that has a us census block group layer. Then either use an overlay function from one of the mapping packages for example, or instead of using shape files convert file to data frame and use a join function for example from "ggplot" and "ggmap" to match the lat and long to the 14 digit census block group value.

## Example of results: ##
GEOID10              LAT        LONG  
1. 1005950300123    +31.7908933 -085.5670514  
2. 01005950900134   +31.8467221 -085.1462332  
3. 01005950800145   +31.9206930 -085.1760317  
4. 01005950700156   +31.9440855 -085.2620842  
5. 01005950600167   +31.8783526 -085.2729215  
6. 01005950100178   +32.0353533 -085.2477678  
7. 01005950400189   +31.6794432 -085.5577196  
8. 01005950200200   +31.9222753 -085.4498309  
9. 01005950500211   +31.7634183 -085.2718649  
10. 01027959000222  +33.3093759 -085.8820883  
11. 01027959200233  +33.1781831 -086.0215486  
12. 01027958900244  +33.3872783 -085.7690615

I am searching for a us census block group shape file to use in R. A shape file that might work is a separate download for all US states using Tiger files at US census site along with the necessary support files (".shp, .dbf, .prj etc.") making using this file problematic because it would result in a couple of hundred needed files.

Also checked the UScensus2010 package but it doesn't yet have the 'install.blkgrp' function set up. I'm reaching out to get some ideas or direction on what is the best way to do this.

Thank you

Serban Tanasa
  • 3,592
  • 2
  • 23
  • 45
user3067851
  • 524
  • 1
  • 6
  • 20
  • Do you have access to ESRI Arc-GIS or the freeware Q-GIS? You could import the individual state-level shapefiles and Geoprocessing -> Merge them all... There is a reason why they're in separate files though -- they will get huge. – Serban Tanasa Apr 16 '15 at 23:10
  • I think your intuition is right...but @Serban if you start to need this for more than 5-10 states things are going to get really big. – miles2know Apr 17 '15 at 01:13
  • I need all 50 + states. There has to be a better way. Thank you for trying,Ill let you know what I find. – user3067851 Apr 17 '15 at 02:11
  • Hi - did you ever find an answer to this? I am also working with several thousand addresses in R and trying to append census tracts (and eventually make a map of data within each tract) – garson May 30 '15 at 14:36
  • Almost. I downloaded all census tract blocks for the 50 + states. Then I opened all of the states in a single call to qmap and it worked. I opened the map and the blocks were there. However, opening all of the shape files required a lot of memory (RAM). I had to upgrade to 16GB and sometimes my PC still hangs. So, I haven't gotten to plotting the addresses on the map yet due to the hanging issue. When this is done, I will use an overlay to append geocodes. I try to save the objects when I close R but it doesn't save them. I always have to reload which is a problem. – user3067851 May 31 '15 at 20:40

1 Answers1

1

I found this was the easiest way to download census tract shape files using R:

if (("tigris" %in% rownames(installed.packages()))==FALSE)install.packages("tigris"); library(tigris)
if (("ggplot2" %in% rownames(installed.packages()))==FALSE)install.packages("ggplot2"); library(ggplot2)

census.tracts <- tracts(state="NJ")
plot(census.tracts)
census.tracts.fort <- fortify(census.tracts)

This piece of code will give you a census tract shape file for the state of New Jersey. Late to the party I know, but I hope this process can help others.

YimYames
  • 99
  • 1
  • 12