Painting a Map of Racial Disparity in State Prisons using Felt

Quy
5 min readDec 2, 2022

--

Black people are disproportionately placed in prison systems compared to other races in America. Today I am going to walk you through how I built this map visualization of racial disparity in state prisons in America using Felt as well as what I learned. I hope this map visualization can allow you to contextualize and better understand where your current state prison system compares to others around the country.

Black/White Disparity in State Prisons using Felt

What is racial disparity?

Racial disparity is the imbalance between the treatment of various racial groups when it comes to economics, healthcare, access, and opportunties. In the U.S. prison system, the total average rate at which a black person is placed in prison versus a white person is almost 5:1. In New Jersey, this ratio is roughly 12:1! This is pretty scary data.

  1. Coding

The first challenge involved with building out this map visualization was modifying the GeoJSON file of the various states to include key data from the sentencing project. The GeoJSON file needed to include additional properties such as: Imprisonment Rate Per 100k residents, Black/White Disparity, Latinx/White Disparity, Youth Custody Rate Per 100k youth, Felony Disenfranchisement Rate. While you could manually add this data, I ended up doing it programatically. The first step was reading the CSV file containing data from the Sentencing Project.

const csv = require('fast-csv');
const path = require('path');

function getStatesInfo(){
return new Promise((resolve, reject) => {
const filePath = path.dirname(__dirname) + '/SentencingProjectDataset.csv'
var states = [];
csv.parseFile(filePath, {headers: true})
.on("data", state => {
states.push(state);
})
.on("end", () => {
resolve(states)
});
}
)}

The next step involved reading in the GeoJSON file and mutating the data to essentially merge the dataset with the GeoJSON file.

const fs = require('fs');

fs.readFile('states.json', async (err, data) => {
if (err) throw err;
let rawFile = JSON.parse(data);
let features = rawFile.features
const states = await getStatesInfo()

features.forEach(feature => {
const currentState = states.find(state => state?.State === feature?.properties?.NAME )
if(currentState){
feature.properties["BLACK/WHITE DISPARITY"] = currentState['Black/White Disparity']
feature.properties["IMPRISONMENT RATE PER 100K RESIDENTS"] = isNaN(Number(currentState['Imprisonment Rate Per 100k residents'])) ? "-" : Number(currentState['Imprisonment Rate Per 100k residents'])
feature.properties["LATIN/WHITE DISPARITY"] = currentState[ 'Latinx/White Disparity' ]
feature.properties["YOUTH CUSTODY RATE PER 100K YOUTH"] = isNaN(Number(currentState['Youth Custody Rate Per 100k youth'])) ? "-" : Number(currentState['Youth Custody Rate Per 100k youth'])
feature.properties["FELONY DISENFRANCHISEMENT RATE"] = currentState['Felony Disenfranchisement Rate']
feature.properties["IMPRISONMENT RATE PER 100K BLACK RESIDENTS"] = rate
}
})
}

The final step involved saving the data to a new file and writing it to your file system. This file would later be uploaded on Felt.

const fs = require('fs');    
fs.writeFile('prisonData.json', JSON.stringify(rawFile,null, 2), (err) => {
if (err) throw err;
console.log('Data written to file');
});

2. Uploading the GeoJSON file to Felt

Felt is a tool which you can use to easily build maps. I used the upload feature to get all the various shapes of the states to appear on the map.

Uploading GeoJSON file to Felt

3. Styling the Map

I used a combination of the Felt Style Editor & Felt Style Language in order to style the map. The first step involved changing the type of map from simple to category and setting the Color By field to the Imprisonment Rate.

From here I proceeded to open up the Advanced Editor.

In order to specify the specific color for each state based on imprisonment rate, I ended up having to modify the legend, categories, and color.

The legend needed to be converted to an object where the key is the value of the imprisonment rate and the value of that key is the name of the state.

{ "2400" : "Hawaii", "2600" : "Mississippi" } // ...etc

The categories were an array of all the unique values of the imprisonment rate.

[2400,2600] // ...etc 

In order to generate the colors I used two tools. The first tool being Gradient Generator (https://colordesigner.io/gradient-generator) and arrayThis (https://arraythis.com/). You want to generate enough color codes for the number of categories you have which in my case was 40 unique values for imprisonment rates. I chose to set the start and end color white and black since I was really interested in the Black/White disparity in the state prison system.

After this, copy the hex-codes into arrayThis because the color property within Felt expect specific syntax. Felt updates the map in real time. After you finish, make sure you click Done. To find more information on Felt Style Language you can go to this resource https://feltmaps.notion.site/Felt-Style-Language-0f4de46f0cf2450ea2a19853741097d6#949d945cd30f4e7a8bf9fc51c675f690 .

"color" : ["#ffffff", "#f8f8f8", "#f0f0f0", "#e9e9e9", "#e2e2e2", "#dadada", "#d3d3d3", "#cccccc", "#c5c5c5", "#bebebe", "#b7b7b7", "#b0b0b0", "#a9a9a9", "#a2a2a2", "#9b9b9b", "#959595", "#8e8e8e", "#878787", "#818181", "#7a7a7a", "#747474", "#6d6d6d", "#676767", "#616161", "#5b5b5b", "#545454", "#4e4e4e", "#484848", "#434343", "#3d3d3d", "#373737", "#313131", "#2c2c2c", "#262626", "#212121", "#1c1c1c", "#171717", "#111111", "#090909", "#000000"]

Final Notes

It is quite rough to look at the final map with all the data incorporated. Some parts of the country black people are disproportionally placed in the state prison system. I do not think it is fair to represent an entire state by a few data points. I do however think it is fair to continue to challenge those in power to re-examine our justice system. After all, if somebody was imprisoned for marijuana use 10 years ago, should they still be imprisoned for life while the state has legalized it?

Check out the map on Felt:

Do you have questions or feedback? I would love to hear it!

email: ducquynguyen520@gmail.com

twitter: https://twitter.com/duckduckquy

Felt: https://felt.com/

Data Source: https://www.sentencingproject.org/research/us-criminal-justice-data/

GeoJSON: https://eric.clst.org/tech/usgeojson/

--

--

Quy

Developer by day, sometimes chef at night. Documenting my journey at making maps.