Skip to contents

Conditioned Latin Hypercube Sampling using clhs functionality.

Usage

sample_clhs(
  mraster,
  nSamp,
  iter = 10000,
  cost = NULL,
  existing = NULL,
  access = NULL,
  buff_inner = NULL,
  buff_outer = NULL,
  plot = FALSE,
  details = FALSE,
  filename = NULL,
  overwrite = FALSE,
  ...
)

Arguments

mraster

spatRaster. ALS metrics raster.

nSamp

Numeric. Number of desired samples.

iter

Numeric. Value giving the number of iterations within the Metropolis-Hastings process.

cost

Numeric/Character. Index or name of covariate within mraster to be used to constrain cLHS sampling. If default (NULL), a cost constraint is not used.

existing

sf 'POINT'. Existing plot network.

access

sf 'LINESTRING' or 'MULTILINESTRING'. Access network.

buff_inner

Numeric. Inner buffer boundary specifying distance from access where plots cannot be sampled.

buff_outer

Numeric. Outer buffer boundary specifying distance from access where plots can be sampled.

plot

Logical. Plots output strata raster with samples.

details

Logical. If FALSE (default) output is only stratification raster. If TRUE return a list where $details is additional stratification information and $raster is the output stratification spatRaster.

filename

Character. Path to write output samples.

overwrite

Logical. Choice to overwrite existing filename if it exists.

...

Additional arguments for clhs sampling. See clhs.

Value

An sf object with nSamp stratified samples.

References

Minasny, B. and McBratney, A.B. 2006. A conditioned Latin hypercube method for sampling in the presence of ancillary information. Computers and Geosciences, 32:1378-1388.

Minasny, B. and A. B. McBratney, A.B.. 2010. Conditioned Latin Hypercube Sampling for Calibrating Soil Sensor Data to Soil Properties. In: Proximal Soil Sensing, Progress in Soil Science, pages 111-119.

Roudier, P., Beaudette, D.E. and Hewitt, A.E. 2012. A conditioned Latin hypercube sampling algorithm incorporating operational constraints. In: Digital Soil Assessments and Beyond. Proceedings of the 5th Global Workshop on Digital Soil Mapping, Sydney, Australia.

Author

Tristan R.H. Goodbody

Examples

#--- Load raster and existing plots---#
r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)

e <- system.file("extdata", "existing.shp", package = "sgsR")
e <- sf::st_read(e)
#> Reading layer `existing' from data source 
#>   `/home/runner/work/_temp/Library/sgsR/extdata/existing.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 200 features and 1 field
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 431110 ymin: 5337710 xmax: 438530 ymax: 5343230
#> Projected CRS: UTM_Zone_17_Northern_Hemisphere

a <- system.file("extdata", "access.shp", package = "sgsR")
ac <- sf::st_read(a)
#> Reading layer `access' from data source 
#>   `/home/runner/work/_temp/Library/sgsR/extdata/access.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 167 features and 2 fields
#> Geometry type: MULTILINESTRING
#> Dimension:     XY
#> Bounding box:  xmin: 431100 ymin: 5337700 xmax: 438560 ymax: 5343240
#> Projected CRS: UTM_Zone_17_Northern_Hemisphere

sample_clhs(
  mraster = mr,
  nSamp = 200,
  plot = TRUE,
  iter = 100
)

#> Simple feature collection with 200 features and 4 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 431130 ymin: 5337710 xmax: 438550 ymax: 5343230
#> Projected CRS: UTM Zone 17, Northern Hemisphere
#> First 10 features:
#>        zq90 pzabove2  zsd type               geometry
#> 43709 14.40     64.5 3.82  new POINT (437310 5340690)
#> 10100 17.50     68.2 5.28  new POINT (431710 5342630)
#> 63672  5.32     17.2 1.35  new POINT (434950 5339490)
#> 66836  7.58     47.9 1.91  new POINT (436690 5339290)
#> 66535  9.41     82.0 2.32  new POINT (436490 5339310)
#> 18693  9.64     59.9 2.59  new POINT (431590 5342130)
#> 40096 19.50     92.5 5.15  new POINT (438470 5340910)
#> 76682 20.10     95.1 3.39  new POINT (434750 5338530)
#> 17710 13.80     92.5 2.72  new POINT (433930 5342190)
#> 10363  3.62     13.0 0.72  new POINT (437750 5342630)

sample_clhs(
  mraster = mr,
  nSamp = 400,
  existing = e,
  iter = 250,
  details = TRUE
)
#> $clhs
#>   [1] 10033 58648  2257 47724 11317 16691 72419  6227 79031 29845  6611
#>  [12] 84313 18514 39896 17344 53780 67964 10669 26250 37033 87893 62551
#>  [23] 54675 14193  8222 13577 43986 42433 71148 15001 45256 77870 66230
#>  [34] 23121   192 16008   599 50817 24564 79412 39414 58152 27490 11875
#>  [45]  8593 14278  8650 12257  6806 85750  3863 32488  4113 20141 86831
#>  [56] 80763 49979 46580 73499 30856  7715 87165 31763 73828 28335 87702
#>  [67] 91161 86624 34345  9098 60653 50651 19374 23817 36394 46860 31915
#>  [78] 40037 28433 37990 40386   808 15986 82026 69243 75487  4560 26442
#>  [89] 25871 57725 54063 62742 47338   182 78165  3485 64125 20187 75666
#> [100]  2967 75331 60400 71651 72141 41015 51924 13191 65448 12701 52095
#> [111] 75443  6394 89421 71931 56744 32117 43476 28073 89042 90594 69352
#> [122] 41637 68972 45047 67797 12362 38046 72666 64600 61748 74038 52317
#> [133] 15888 77739 40208 21451 22810 60904 79184 89201 80261 23505 23907
#> [144] 60815 17493 77976 43298 21911 58797 64262 41308 33263 51026  1062
#> [155] 48675 52577 11226 74878  8737 58173 29037 45826 44668 30069 80771
#> [166] 27182 60282 32802 65533 14146  9392 40218 42747 58967 60202 72801
#> [177] 24272 28571 77022 68945 83364 31628 17302 62215 81394 23043 44929
#> [188] 80430 31670 11789 34418 63739  5017 25825 54418 26569 61061 86187
#> [199] 75547 59877     1     2     3     4     5     6     7     8     9
#> [210]    10    11    12    13    14    15    16    17    18    19    20
#> [221]    21    22    23    24    25    26    27    28    29    30    31
#> [232]    32    33    34    35    36    37    38    39    40    41    42
#> [243]    43    44    45    46    47    48    49    50    51    52    53
#> [254]    54    55    56    57    58    59    60    61    62    63    64
#> [265]    65    66    67    68    69    70    71    72    73    74    75
#> [276]    76    77    78    79    80    81    82    83    84    85    86
#> [287]    87    88    89    90    91    92    93    94    95    96    97
#> [298]    98    99   100   101   102   103   104   105   106   107   108
#> [309]   109   110   111   112   113   114   115   116   117   118   119
#> [320]   120   121   122   123   124   125   126   127   128   129   130
#> [331]   131   132   133   134   135   136   137   138   139   140   141
#> [342]   142   143   144   145   146   147   148   149   150   151   152
#> [353]   153   154   155   156   157   158   159   160   161   162   163
#> [364]   164   165   166   167   168   169   170   171   172   173   174
#> [375]   175   176   177   178   179   180   181   182   183   184   185
#> [386]   186   187   188   189   190   191   192   193   194   195   196
#> [397]   197   198   199   200
#> 
#> $samples
#> Simple feature collection with 400 features and 5 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 431110 ymin: 5337710 xmax: 438530 ymax: 5343230
#> Projected CRS: UTM_Zone_17_Northern_Hemisphere
#> First 10 features:
#>    type  zq90 pzabove2  zsd FID               geometry
#> 1   new 14.60     77.0 3.78  NA POINT (433030 5342650)
#> 2   new 12.80      1.4 4.47  NA POINT (434570 5339810)
#> 3   new  5.32     70.9 1.26  NA POINT (435790 5343110)
#> 4   new 16.60     95.3 2.63  NA POINT (432610 5340450)
#> 5   new 12.70     66.9 2.88  NA POINT (432390 5342570)
#> 6   new 18.50     84.8 5.67  NA POINT (431370 5342250)
#> 7   new 17.40     95.1 3.81  NA POINT (438110 5338890)
#> 8   new 16.20     87.3 3.98  NA POINT (435650 5342870)
#> 9   new 20.30     94.2 3.74  NA POINT (432610 5338390)
#> 10  new 13.20     89.2 2.58  NA POINT (434170 5341510)
#>