[GIS] Calculating percent cover from shapefiles

arcgis-10.0arcgis-desktoprshapefile

I normally do not work with shapefiles, so I am a bit lost here. I have two shapefiles each with multiple objects. The first is a set of 32 polygons (each one is a plot). The second shapefile has >10,000 objects which represent vegetation clusters of different sizes within each plot. I am trying to figure out:

1) How do I calculate percent cover of total vegetation cover within each site?

2) What percentage of each the vegetation cover is less than 5 meters in area in each plot?

This is what my data looks like in ArcGIS for a single plot. I am open to advice on how to do this in arcGIS too.

This link will take you to the shapefiles in my dropbox:
https://www.dropbox.com/sh/wyokxximppexyb3/p7VC-pfF2E

enter image description here

Best Answer

Since you tagged R, here is a solution in R. It is best to not assume that there a column representing area, which is why I am pulling it from the polygon@area slot. In the loop(s) you may notice an interesting way of pulling the values of a specific column based on indexing a different column.

This code will add "pVeg" and "pVeg5" columns to your plots polygon feature class. The pVeg column represent the percentage of all vegetation in the plot and "pVeg5" is the <= 5m percent.

    require(sp)
    require(rgdal)

    # SET WORKING DIRECTORY AND READ DATA
    setwd("D:/TMP/vegplots")
      plots <- readOGR(getwd(), "plots")
      veg <- readOGR(getwd(), "veg_in_plots")

    # ASSOCIATE PLOT IDS TO VEG DATA 
    veg@data <- data.frame(veg@data, LocCode=over(veg, plots[,"LocCode"]))  

    # CALCULATE POLYGON AREAS AND ADD TO DATA 
    plots@data <- data.frame(plots@data, pArea=sapply(slot(plots, 'polygons'), function(i) slot(i, 'area')))
    veg@data <- data.frame(veg@data, vArea=sapply(slot(veg, 'polygons'), function(i) slot(i, 'area')))

    # CALCULATE PERCENT VEG AREA IN EACH PLOT AND ADD TO "plots" data.frame 
    varea <- vector()
    for(i in 1:dim(plots)[1]) {
      varea <- append(varea, sum(veg[veg$LocCode == plots@data[i,]$LocCode ,]$vArea) )
      }
    plots@data <- data.frame(plots@data, pVeg=varea / plots@data$pArea * 100)

    # CALCULATE PERCENT VEG AREA <= 5m IN EACH PLOT AND ADD TO "plots" data.frame
    vsub <- veg[veg$vArea <= 5 ,]
      varea5 <- vector()
        for(i in 1:dim(plots)[1]) {
          varea5 <- append(varea5, sum(vsub[vsub$LocCode == plots@data[i,]$LocCode ,]$vArea) )
        }
    plots@data <- data.frame(plots@data, pVeg5=varea5 / plots@data$pArea * 100)

writeOGR(plots, getwd(), "VegPercents", driver="ESRI Shapefile")
Related Question