Introduction to Data Visualization and Analysis

Public policymakers need to weigh a variety of factors when they are determining how to solve policy problems. Is the policy intervention effective in solving the problem? Does the policy effectively use limited public resources to solve the problem? Do the policies contribute to equity in a diverse society?

Because the problems facing policymakers are extremely complex, it is often a challenge to assess the severety of particular problem and understand the implications of particular policy interventions.

One crucial element that helps policymakers understand problems and devise solutions is through data analysis. Data are understood as facts that speak to particular social conditions. Data can be text, numbers, and other factual information. For policymakers, making complex information understandable is a major job.

There are numerous ways to accomplish this and various tools at policymakers’ disposal to help make sense of data.

In our labs I will provide you with an introduction to a variety of data analysis techniques and technologies.

For the first lab we will look at the visualization of data using maps. All of the tools I will show you are free, open source programs that you can download and install on your own computer.

Chicago’s Community Areas

One major problem facing cities in the United States is that where you live can impact your social opportunities. US cities are highly segregated on the basis of numerous social indicators. In this lab we will visualize urban data using a mapping program called, QGIS.

In the 1920s, social scientists at the University of Chicago divided the city up into more than 70 community areas. The City of Chicago and other researchers and planners routinely collect data aggreagated at the community area level.

In this lab, we will make a simple map of Chicago’s community areas and visualize social data to compare conditions across the city among key social indicators.

Software and Data

The software we are using is called QGIS and is installed on the lab computers. QGIS is a free, open-source and multi-platform software. If you would like to install it on your own computer you can find instructions here.

QGIS requires that we have data to visualize. Since we are visualizing information across the geography of the Chicago, we will need spatial data to form the base of a map.

Many cities have ‘open data’ portals that allow anyone with an internet connection to download governmentally-produced data. For this exercise we will download geospatial data from the City of Chicago’s open data website.

The boundary files for Chicago’s community areas can be found here: https://data.cityofchicago.org/Facilities-Geographic-Boundaries/Boundaries-Community-Areas-current-/cauq-8yn6/data.

Click on the Export button and download the geospatial data as a KML file.

Remember where your file was saved. You may want to save a copy in a directory that you dedicate to your analysis projects.

Now that we have downloaded the basic map data, we can open QGIS and load the KML file. (Note, your QGIS interface may look a little different than what appears on this tutorial as the developers are continually updating the software).

In QGIS, find the Layer dropdown menu and click on Add Layer.

You will want to click on Add Vector Layer. In the box that pops up, navigate in the Source dialogue box to the KML file you downloaded. With the file selected, click Add and then Close.

Now you have a map of the Chicago Community Areas with the boundary file listed in the Layers pane. If you right click on the layer and select Open Attribute Table you will see the underlying tabular data for the community areas.

Scrolling to the right you will see a column titled community that lists the name of each community area.

The community area name is important to know as we will need to refer to this column to bring in our social data.

One interesting data set compiled by Chicago consists of health indicators for each of the city’s community areas. We can find that dataset on the city’s open data portal: https://data.cityofchicago.org/Health-Human-Services/Public-Health-Statistics-Selected-public-health-in/iqnk-2tcu/data

Using the Export button we can export the file in CSV format. Remember where you saved the file.

Now we will go back to QGIS and import our health indicator data. Following the same procedure we used initially, go to the Layer menu in QGIS and then Add Layer. This time we want to select Add Delimited Text Layer.

In the popup, select File Name and navigate to the CSV file you downloaded with the health data. You will also want to select Geometry definition and make sure that the No geometry (attribute table only) box is selected. Then Add the file and Close.

The public health data will now show up in the Layers panel on QGIS. Now we have to connect the health data with the geographical data. This is done by an operation called a table join. Each layer has to have a column with identical values on which to join.

By looking at the attribute table for the health data we see a column called Community Area that lists all of the community areas by their number. In our boundary file, we mentioned above that there is a column called area_numbe that has all of the community area numbers. One problem that we see is that the data type is not consistent. In the Boundary file, the area_numbe values are saved as string, meaning the computer is reading them as text, not numbers.

To get around this problem we need to create a compatible join column. We can do this by opening the attribute table of the health data and then open the field calculator by clicking on its icon.

In the Field Calculator, we first need to give a name to our new variable. I call it “Comm_string” in the Output Field Name. The Output field type should be text. Then in the Expression box, type: to_string( “Community Area” ) and hit OK.

Two perform the join we will need to link these columns. Right click on the Layers panel your Boundaries file and select Properties.

In the popup, navigate to the Joins menu and click the plus sign. For Join field select Comm_string and for Target field select area_numbe and click OK. Then click Apply and OK.

Now if you look at the attribute table for your Boundaries layer you will see all of the health indicator variables added.

To visualize the data we can create a choropleth map that shades the regions in proportion to the value of a particular variable from the health data.

Right-clicking on the Boundaries layer and then selecting the Symbology (on older versions of QGIS, select the Style menu) menu, change the top symbol to Graduated and then select a column that you want to visualize. In this example I am showing the infant mortality rate. For the Mode, I am selecting Quantile. then click Apply and OK.

The final map looks something like this:

What patterns do you see? Could this visualization be useful for policy makers?

Try making your own map using some of the other health indicator variables. To learn more about the variables, detailed information can be found here: https://data.cityofchicago.org/api/assets/2107948F-357D-4ED7-ACC2-2E9266BBFFA2