I am new to R and having a bit of trouble working with two sp data frames.
Data Frames:
- 'violence' (which is a data frame containing instances of violent occurrences, listed by longitude and latitude)
- 'DRC_GEO2' (which is shapefile that includes the administrative boundaries of the DRC).
I want to calculate the number of violent occurrences per administrative territory as defined by the DRC_GEO2 data frame polygons. This post (https://gis.stackexchange.com/questions/110117/counting-number-of-points-in-polygon-using-r/110246#110246?newreg=5bfe0d571b8241158bac704f188cf026) was helpful in outlining a similar issue. However, I do not want to record a sample of data points from "violence", I want all recorded instances in the data frame.
I have tried the below code which does output the correct # of instances, however, it classifies them according to the largest administrative unit ('ADM1_FR') but I would like it to classify by the smallest admin unit ('ADM2_FR').
res <- over(violence_point, DRC_GEO2)
table(res$NAME_1)
Which has returned: enter image description here
Ultimately, I would like a choropleth map of the number of instances of violence over the original shapefile 'DRC_GEO2'. How do I add the number of occurrences per administrative territory to the data in order to make the choropleth map?