DATA: CSV data, Shapefile

Hi all!

I'm looking to perform what I've been taught is called a spatial join. After researching this further, it's looking like this operation is most often called a table join. So sorry for any confusion in the wording!

What I want to accomplish is very straightforward. I have a CSV that contains data for admin boundaries in the Philippines. I have a shapefile of said admin boundaries. I want to join these together in R to make choropleth maps. Easy enough, right?

To do this in QGIS, I simply add the shapefile and CSV as layers. Within the shapefile, Properties -> Joins, then add the join from there. Here's a screenshot for the sake of complete clarity: enter image description here

As you can see, the Admin category of the CSV file matches the REGION category of the shapefile's attributes. Once those are joined, I am easily able to create choropleth maps from any of the other attributes from the CSV. Quick dummy-proof example here: enter image description here

Now how the heck do I do this in R? It seems like it should be really easy to do, but I can't find much information, as all of my queries have yielded results of spatial joins concerning "join attributes by location" from data management tools in QGIS. I am not trying to find out which points fall within x polygons. I simply need to join the CSV to the shapefile so that I can make a choropleth map!

This question seems most similar to what I'm asking, but I couldn't sift through it enough to make sense of what I needed out of it.

  • Use sp::merge just make sure that the x argument is a sp class object. The general arguments are the same as the standard R merge function. Use read.csv to read your csv file and readOGR in the rgdal package for your shapefile. – Jeffrey Evans Nov 16 '15 at 20:14
  • I have added that answer to the question this is a duplicate of, as it did not have a good answer. – Robert Hijmans Nov 17 '15 at 2:00