One of the most surprising things for me is the search terms that lead people to my website. MCP is actually the top search term. So while I discuss the pros and cons of MCP here, apparently there’s a whole lot of people out there who are still interested in utilizing this method.
I’ll outline how to do it in R, QGIS, and ArcGIS. Before beginning, make sure your data is in a projection that will provide meaningful results. I highly recommend you do a transformation into UTM.
Before beginning, please note that ArcGIS and QGIS will only give you the 100% contour. If you want anything less than that, you’ll have to use the R method.
There’s a tool that you can use called the minimum bounding geometry tool. Its located in your toolbox, though licensing issues may restrict whether you have it or not. The steps are as follows:
1. Load your CSV file of coordinates using the add data button. You can also find it by clicking on File > Add Data > Add XY Data.
2. When adding XY Data, you need to make sure you set the projection (ideally its in UTM).
3. Open up your toolbox. You can find it by clicking Geoprocessing > Arc Toolbox.
4. The minimum bounding geometry tool can be found in Data Management Tools > Features > Minimum Bounding Geometry. Click it.
5. A new window will appear. Under input features, select your csv.
6. Set your output feature class to wherever it is you would like to save the shape file that the tool will generate.
7. Under geometry type, select convex hull. Click OK and your minimum convex polygon will be generated.
8. Right click, open attribute table, and your area will be listed. As long as your projection is UTM, it will be in meters squared.
In QGIS 3 (I’m currently using the LTR 3.4 version), the minimum convex polygon can be created using the minimum bounding geometry tool. The steps are as follows:
1. Load your CSV file of coordinates using the Add Delimited Text Layer menu option. To access this, click on Layer > Add Layer > Add Delimited Text Layer
2. Open up the processing toolbox. To do this, click on Processing > Toolbox.
3. A panel called processing toolbox should now open. On my copy of QGIS, its on the right side of my screen. In the search bar found at the top, type in minimum bounding geometry. It should appear nested under Vector geometry. Click on it.
4. A new window will pop up. In the input layer, your delimited text layer (which you created in step 1), should be automatically populated.
5. Click run. Your minimum convex polygon, or MCP, should now be added as a layer.
6. Right click on the layer, and navigate to open attribute table. Your area is now listed. If you used UTM as I recommended, your units are meters squared.
To begin with, you’ll need a few packages. These packages are adehabitatHR, rgdal, and sp. One word on data prep. In your CSV file, I recommended you change the name of the column with the X coordinates to x and the column with the y coordinates to y. It’ll make coding a lot faster.
As a final note, if you’re copying and pasting the code, please note that the quotation marks may not copy properly. If you run into errors running the code, I would recommend that you type it out.
install.packages(c(‘adehabitatHR’, ‘rgdal’, ‘sp’))
While I’m sure there are other packages that can calculate a MCP for you, I primarily default to adehabitatHR. Make sure you load all the packages.
libraries(“adehabitatHR”, “rgdal”, “sp”)
The data prep is what makes R a little bit more annoying. However, it is definitely a lot more powerful than the tools you have available in QGIS and ArcMap. You’ll need to load your CSV into R. Don’t forget to set your working directory to where ever it is your CSV file is kept. I’m assuming that you have a header row.
a <- read.csv(“your_csv.csv”, header = TRUE)
Now we need to convert the CSV file we just read into a spatial points dataframe. Don’t forget that we need to assign the projection. You did do a transformation to UTM, didn’t you?
a.xy <- a[c(“X”,”Y”)]
a.spatial <- SpatialPoints(a.xy)
proj4string(a.spatial) <- CRS(“+init=epsg:12345”) #change the espg to the epsg of your UTM Zone
And there you go. A projected spatial data frame. Now time for what you came here for. How to calculate the MCP. By default, the mcp() function will generate a 95% contour. You can modify the percent for your needs. If you projected to UTM, you don’t need to set the unin argument as the default unit is meters.
mcp(a.spatial, percent=95, unin = “m”, unout = “m2”)
When you run this line of code, it will tell you the area. Now, if you want to export it to a CSV or export it as a shapefile, the following lines of code will do that for you.
b <- mcp(a.spatial, percent=95, unin = “m”, unout = “m2”) #must run this line
write.csv(b, file = “test.csv”) #this will write your csv file
writeOGR(b, “.”, “Somefilenamehere”, driver = “ESRI Shapefile”) #this will write your shapefile