I have a land use raster (lu_raster) and several thousand shapefiles (counties). Within each county, I'd like to calculate the proportion of agricultural land use. So, I think I need to find a way to 1). sum all the raster pixels that are either value 81 or 82 (see here for reference) within each of the shapefiles, and 2). divide that by the total number of pixels in each of the county shapefiles.
I've been using
exact_extract to do this kind of stuff. So I think the second part of my code will look something like this:
Results <- exact_extract(lu_raster, counties, 'count')
But I can't figure out how to do those counts conditionally (only counting the 81s and 82s).