【问题标题】:Issues Running the updated version of grts() within the package spsurvey在包 spsurvey 中运行更新版本的 grts() 的问题
【发布时间】:2022-11-22 07:42:00
【问题描述】:

使用 spsurvey 的更新版本,我很难尝试使用 grts() 函数为我的设计生成随机点。使用下面的代码,如果 n_over =一些数字并在所有阶层中得出该数字。但是,我希望根据英亩对每个层进行不同数量的过采样。第一段代码起作用并绘制适量的基点,然后每层产生 10 个以上的样本点

但是,当我尝试对 n_over (Over.test) 执行类似操作时,我收到此错误消息

" 输入错误信息 n_base + n_over :对于每个层,基站点和'Over'替换站点的总和必须不大于代表该层的'sframe'中的行数。”

即使在 test.inShape<-st_read("UFO_2022_Ints_Pts_Strata.shp") 中每个层有 115 多行

不幸的是,关于更新的 spsurvey 包的信息很少。

“ALLOT_NAME”是形状文件中的一列,其中包含每个层的名称(Adobe、Big Pasture 等...)

Stackoverflow 的新手,如果我没有适当地介绍这个,我深表歉意

### 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
# )

【问题讨论】:

    标签: r function random


    【解决方案1】:

    抱歉在这里回复晚了!我认为您收到的错误是我们的一项错误检查中出现错误的结果。此错误将在 spsurvey 的 5.4.0 版中修复,应该会在接下来的几周内出现在 CRAN 上。我希望您的代码在安装新版本后能够正常工作。此外,spsurvey 有一个新的网站可以查看here,其中包含很多关于包的信息。

    至于在 Stack Overflow 上“适当呈现”,通常您想提供一个可重现的示例(更多关于 herehere)。考虑到这个错误的性质,我认为提供一个可重现的例子是很有挑战性的。因此,感谢您提供了所有代码。

    【讨论】:

      猜你喜欢
      • 2021-12-25
      • 1970-01-01
      • 2020-11-24
      • 1970-01-01
      • 2019-01-09
      • 1970-01-01
      • 2017-12-05
      • 2019-08-04
      • 1970-01-01
      相关资源
      最近更新 更多