Mapping homicides in Retiro

For this exercise, you should create the R code needed to make a basic map of the locations of homicides in the Retiro neighbourhood of Buenos Aires, Argentina, in 2023.

Before you start

Complete Chapters 1–2 of Learn Crime Mapping with R.

In this exercise you will practise downloading and reading data, converting coordinates into a spatial object, and creating a point map. The coordinate-system codes needed for this dataset are supplied below.

What your map should show

Your map should show the locations of individual incidents between 1 January and 31 December 2023, inclusive. You can download the data from:

https://mpjashby.github.io/crimemappingdata/retiro_homicides.csv

The dataset documentation describes the columns and source. Although the column names are in Spanish, the file uses commas to separate values, so read it with read_csv() rather than read_csv2().

This dataset uses the WGS84 coordinate reference system, which has the EPSG code EPSG:4326. Before creating the map you should transform the dataset to use the POSGAR 2007 / Argentina 6 coordinate system (EPSG:5348).

Checklist for this exercise

You can use this checklist to make sure you have done everything required for this exercise.

The map

  • The map shows the locations of individual incidents in 2023.
  • The map includes a background map so viewers can identify the locations.
  • The points use a colour that stands out from the background.

The code

  • There is no temporary code – e.g. head(), excel_sheets(), install.packages(), etc. – in your script file.
  • The code loads the necessary packages at the start of the script in a single call to the pacman::p_load() function.
  • The code uses request() and req_perform() to download the data to a local file in the data/raw folder.
  • The code uses here() to specify file paths within your workspace.
  • The code loads the downloaded local file into R.
  • The code converts the data to a simple features (SF) object using EPSG:4326.
  • The code transforms the dataset to use a local coordinate reference system.
  • The script contains all the code needed to produce the map.

Check your answer

After attempting the task, you can read this specimen answer and explanation to get an idea of what a potential solution looks like.