2

With the updated version of spsurvey I am having a difficult time trying to generate random points for my design using the grts() function. With the code below I can produce points if n_over = some number and it draws that number across all strata. However I would like a different number of oversamples per stratum based on acres. The first bit of code works and draws the right amount of base points then produces 10 over sample points per stratum

However when I try to do something similar for n_over (Over.test) I receive this error message

" Input Error Message n_base + n_over : For each stratum, the sum of the base sites and 'Over' replacement sites must be no larger than the number of rows in 'sframe' representing that stratum."

Even though there are 115+ rows per strata in the test.inShape<-st_read("UFO_2022_Ints_Pts_Strata.shp")

There is unfortunately very little information out on the updated spsurvey package.

"ALLOT_NAME" is a column within the shape file that contains the name for each stratum (Adobe, Big Pasture, ect...)

New to Stackoverflow so I apologize if I have not presented this appropriately

### Working code ####
test.prj=c("UFO_2022_Ints_Pts_Strata")
test.inShape<-st_read("UFO_2022_Ints_Pts_Strata.shp")
plots.df<-read.csv("GUSG_Strata.csv")
strata.list<-as.vector(plots.df)
x<-c('Adobe' = 2, 'Big Pasture' = 2, 'Black Ridge' = 45, 'Blue Cimarron' = 2, Buck = 2, 'Crawford Reservoir' = 2, 'Dave Wood Road' = 2, 'Dry Cedar' = 2, 'East Gould Reservoir' = 2, 'Gould Reservoir' = 20, 'Green Mountain - Middle' = 35, 'Grizzly Gulch' = 2, 'Iron Canyon' = 15, 'Little Baldy' = 2, 'Lower Horsefly' = 35, 'Onion Valley' = 2, 'Poison Spring' = 15, 'Rawhide - Coffee Pot' = 2, 'Rim Rock' = 2, 'Shinn Park' = 2, 'Tappan Creek' = 2, 'Green Mountain - Jensen Ware' = 15, 'Green Mountain - West' = 35, 'Green Mountain - East' = 30)

#test.sample<-grts(design=test.design, DesignID="RGFO_2022_RangeLPI", in.shape=test.inShape, id = "RGFO_2022_RangeLPI", prjfilename=test.prj, out.shape="RGFO_2022_RangeLPI_GRTS")
test.sample<-grts(test.inShape, n_base=x, stratum_var="ALLOT_NAME", n_over=10, DesignID="UFO_2022_GUSG" )
test.output<-sp_rbind(test.sample)
st_write(test.output, "UFO_2022_GUSG_SampleDesign_V1_TESTErase.shp")


# will not work when I use n_over = Over.list  trying to specify oversample points for each strata


Over.list <- c('Adobe' = 3,
                 'Big Pasture' = 3,
                 'Black Ridge' = 10,
                 'Blue Cimarron' = 3,
                 'Buck' = 3,
                 'Crawford Reservoir' = 3,
                 'Dave Wood Road' = 3,
                 'Dry Cedar' = 3,
                 'East Gould Reservoir' = 3, 
                 'Gould Reservoir' = 3, 
                 'Green Mountain - Middle' = 10,
                 'Grizzly Gulch' = 3,
                 'Iron Canyon' = 10,
                 'Little Baldy' = 3,
                 'Lower Horsefly' = 10,
                 'Onion Valley' = 3, 
                 'Poison Spring' = 10,
                 'Rawhide - CoffeePot' = 3,
                 'Rim Rock' = 3,
                 'Shinn Park' = 3, 
                 'Tappan Creek' = 3, 
                 'Green Mountain - Jensen Ware' = 10,
                 'Green Mountain - West' = 10,
                 'Green Mountain - East' = 10)

### Below is the layout of the grts function
# grts
#   sframe,
#   n_base,
#   stratum_var = NULL,
#   seltype = NULL,
#   caty_var = NULL,
#   caty_n = NULL,
#   aux_var = NULL,
#   legacy_var = NULL,
#   legacy_sites = NULL,
#   legacy_stratum_var = NULL,
#   legacy_caty_var = NULL,
#   legacy_aux_var = NULL,
#   mindis = NULL,
#   maxtry = 10,
#   n_over = NULL,
#   n_near = NULL,
#   wgt_units = NULL,
#   pt_density = NULL,
#   DesignID = "Site",
#   SiteBegin = 1,
#   sep = "-",
#   projcrs_check = TRUE
# )

Tapr5280
  • 21
  • 2

1 Answers1

0

Sorry for the late response here! I think the error you are receiving is the result of a bug in one of our error checks. This bug will be fixed in version 5.4.0 of spsurvey, which should be on CRAN within the next couple weeks. I am hopeful your code will work once the new version is installed. Additionally, spsurvey has a new website viewable here that contains a lot of information about the package.

As for "presenting appropriately" on Stack Overflow, usually you want to provide a reproducible example (more on that here and here). Given the nature of this bug, I think that providing a reproducible example would have been challenging. Thus, I appreciate that you provided all of your code.

EDIT: spsurvey version 5.4.0 was pushed to CRAN on November 22, 2022.