Income Data Map



This map displays information about income in Lancaster County, Pennsylvania. While statistical data is very important, a graph of the data is an introduction that most people can follow. The purpose of a data map is to illustrate data but we still need some typical map information such as roads and landmarks to help locate boundaries for data areas such as census tracts and zip codes.

We use R language tools and packages that have been developed for Census Bureau maps. These tools have been recently modified to accommodate changes at the Census Bureau to provide information at more secure “https” web addresses.



Download Census Data

gis_tracts <- tracts(state = 'PA', county = c('Lancaster '))
income_data <- acs.fetch(endyear = 2014, geography = geo.make(state = "PA",
                          county = "Lancaster", tract = "*"), 
                          variable = "B19013_001", key=censusapikey)



We extract the GIS and income data from the downloaded objects. The GIS information for census tract areas matches the areas for the income census data.



GIS Information for New Holland, Pennsylvania in Lancaster County

xlong <- -(76.08778 + 76.0877)/2
ylat  <-  (40.10222 + 40.102095)/2



Layered Maps made with Leaflet

In order to plot census data on the map we make a layered map using the Leaflet package. This will allow us to add census tract areas such as polygons below. The basic leaflet addTiles() function includes some roads and landmarks to help locate areas on the map. There are many alternatives to the basic addTiles layout from other mapmakers. Here is the default map before adding the income data. We have zoomed-in in order to see where New Holland is located.

nh <- leaflet() %>%
                addProviderTiles(providers$OpenStreetMap) %>%
                addPopups(-76.11, 40.112,
                    "New Holland, Pennsylvania",
                    options = popupOptions(closeButton = FALSE)) %>%
                setView(xlong, ylat, zoom = 12)
nh



Add Median Income for Lancaster County

We add income as color-coded areas on the map using Leaflet. The census tract areas are defined by GIS information. Here we have zoomed out by one step in order to show income for nearby census tracts. Press zoom-in once to match the same area as the plot above.