Lec16
Loading Shapefiles into R + Social Explorer
Announcements
- From Wednesday’s Discussion: The Big Lies People Tell In Online Dating. In particular scroll to the bottom for the discussion on self-reported bisexuality vs actual bisexuality as represented by messaging behavior.
In-Class
- Slides: Building a choropleth map of Vermont’s census tract by census tract population.
- In-class exercise:
- Data: Unzip
VT_shapefiles.zip
- Code:
Lec15_solutions.R
in Lec15Lec16.R
- Data: Unzip
Using Social Explorer
We will now use Social Explorer’s nice point-and-click interface to download census data.
- Create an account on Social Explorer using your Midd email
- Create a new project
- Select geographical aggregation level
- In top middle of page, select “Show data by State” and turn Automatic to OFF
- Select “Census Tract”
- Select survey: Decennial census, American Community Survey, etc.
- On top right of page, click the Settings button (3 horizontal bars) and select create report.
- On right hand panel select
- Select a survey: Census 2010
- Select a topic: Comprehensive is a good choice
- Select all Vermont census tracts
- Zoom into VT
- On the top right of map select Circle
- Cast a wide net so that all census tracts in VT are captured
- Output results to CSV
- Click “Create Report”
- Select “Data Download” tab
- Download the CSV and Data dictionary (variable codebook)
Installing Necessary Geospatial Packages on macOS Take 2
- Install
brew
by following by the instruction here: http://brew.sh/, following any instructions that may pop up.brew
is a package manager for macOS that makes it much easier to UNIX (not R) packages onto macOS, which runs on a UNIX system. - Install the UNIX version of the
geos
andgdal
geospatial packages. These are packages that allow you to work with maps (project the globe onto a 2D page, import shapefiles, etc.). Run the following two lines in Terminal, following any instructions that may pop up.brew install geos
brew install gdal
- Install the
rgeos
andrgdal
R packages. These are R packages that allow R to interface with the above geospatial packages. Run the following two lines in R:install.packages("rgeos", repos="https://cran.rstudio.com/", type="source")
install.packages("rgdal", repos="https://cran.rstudio.com/", type="source")