As is true all over the world, not every neighborhood is created equal. I thought it would be interesting to get a view of how the different barrios of Argentina's capital compare to cities I'm familiar with in the USA and elsewhere in the world.

Specifically, I'm going to look at two measures: Homicide Rate (per 100,000 people), and Population Density (per square kilometer). See "Methodology" section below for more details.

Note: All visualizations below were built by hand using d3.js. If you'd like a closer look at the underlying code and data, feel free to peruse this observable notebook.

Homicide Rates by Barrio

Annual homicides per 100,000 residents. Overlay of latitude and longitude points for each homicide, 2016 - 2019.

Interesting that Puerto Madero (the wealthiest, most secure "neighborhood") would be relative to Chacarita, my old barrio with it's little villa. We can see pretty clearly the "medialuna sur" - ConstituciĆ³n, Barracas, Nueva Pompeya, Villa Soldati, and Bajo Flores.

Retiro's very high rate is very clearly a function of its villa miseria (informal, unsafe encampment, slum), in Buenos Aires, the Villa 31. In fact, we can see clusterings of points (individual homicides) around villas - note clusters around ConstituciĆ³n and Villas 31, 21-24, 1-11-14.

Homicides from 2016-2019

By Month, Weekday, and Hour.

As we can see from the above radial charts, weekends during late hours seem to correspond to the most "homicidal" times.

Population Density by Barrio

Residents per square kilometer, scale in thousands.

Almagro and Balvanera are an interesting case of bordering, similarly sized, similarly populated, similarly dense barrios with vastly different homicide rates. Unfortunately, at this higher level of "barrio" we can't really get a good sense of whether there is a relationship between density and the homicide rate.

I assumed that perhaps you'd see a relationship since we do see clusterings around the villas, which are densely populated. However, that density is then diluted by the surrounding areas.

Methodology

The Buenos Aires city government publishes data regarding "delitos," crimes.

One such crime is homicidio doloso, specifically homicide with criminal intent.

First, I filtered the data for the four years 2016 - 2019 (nearly half a million rows) to remove any incidents which did not meet the following condition:

tipo_delito === "Homicidio" && subtipo_delito === "Doloso"

I was left with 509 observations, 496 of which have data about the neighborhood (henceforth interchangeably referred to as barrio) where the crime occured and even include specific latitude and longitude coordinates.

Next, I pulled in population data for each barrio as of 2010. The population has certainly grown in the last decade, but I do not want to manipulate this data to try to project that growth and risk understating the homicide rate for any given barrio, so I leave this as a caveat, knowing that in all likelihood I'm overstating the homicide rate. This to me is the more honest, cautious error to make.

Next, I used a GeoJSON file of the neighborhoods of the city which includes as one of its feature properties a measure of square meters. I simply divided this by 1e6 (1,000,000) to determine the area by square kilometer. These results were very close to other statistics I was able to find online.

To calculate homicide rate I averaged the number of homicides per barrio per year, summing the data for 2016 - 2019 for each barrio and dividing by 4 (years), then dividing that number by the population of the barrio divided by 1e5 (100,000). This ultimately renders the "average" homicide rate per 100,000 residents for the years 2016 - 2019.

Values for benchmark homicide rates and population densities came from the following Wikipedia pages.