I've completed a landcover classification on an Landsat Image and would like to start an accuracy assessment. I'd like a stratified random sample that has a sample number that varies based on each landcover values total image pixels. In other words a proportional stratified random sample.
My code so far is the following
spdf = sampleStratified(FinalClassImg, 200, sp = T)
This generates 200 points per landcover class but what I really need is a variable number of samples based on the overall landcover pixel totals.
I roughly calculated the percentages in the image and decided to use 5000 total points. I multiplied the percentages * 5000 and got the following numbers for the nine landcover classes
100, 439, 643, 172, 194, 45, 39, 27, 3341
These numbers represent the number of random samples I'd like selected within each landcover class.
I would like to feed this set of numbers into the above code in place of the 200
I tried this:
spdf = sampleStratified(FinalClassImg, c(100, 439, 643, 172, 194, 45, 39, 27, 3341), sp = T)
but I get a mess of warnings
*1: In if (nrow(y) < size) { ... : the condition has length > 1 and only the first element will be used
- fewer samples than requested found for strata: 2, 3, 4, 5, 9*
and only the first number is used (100 samples per class).
Is there a way to do this or does the sampleStratified only work with a single number?