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: 431110 ymin: 5337750 xmax: 438430 ymax: 5343170
#> Projected CRS: UTM Zone 17, Northern Hemisphere
#> First 10 features:
#>        zq90 pzabove2  zsd type               geometry
#> 44480 11.50     83.1 2.79  new POINT (431410 5340630)
#> 32859 14.60     91.2 4.21  new POINT (435370 5341330)
#> 40700 12.50     84.7 2.95  new POINT (437350 5340870)
#> 36761 19.00     89.4 4.29  new POINT (438250 5341110)
#> 58043 14.20     82.8 3.84  new POINT (432030 5339830)
#> 53818 18.30     85.8 5.32  new POINT (435710 5340090)
#> 74472 16.90     93.3 3.13  new POINT (433310 5338690)
#> 63440 15.40     90.1 3.69  new POINT (437110 5339510)
#> 68846  8.48     34.0 2.31  new POINT (435050 5339150)
#> 4577  11.30     70.4 3.09  new POINT (435950 5342950)

sample_clhs(
  mraster = mr,
  nSamp = 400,
  existing = e,
  iter = 250,
  details = TRUE
)
#> $clhs
#>   [1] 82074 32995 82851 41232 80732  2814 27478 12142 33114 57023 73875
#>  [12] 49848 85394 65469 48394 33683 90296  4900 22573  3983 44804 69084
#>  [23] 78633 45976 31410 28167 30260 33299 49393 78859 43940 61097 17148
#>  [34] 71132 45238 59924 38527 80634 51197 73665 84998 65345 30663 29882
#>  [45] 62299 16478 13441 76296 74626 38372 45223 61919  8120 15258 22807
#>  [56] 79274   395 21846 11411  8045 89946 47262 56380 76802 46719 60001
#>  [67] 61983  1246 46349 40699 78709 77664 29395 15426 89771 52796 85071
#>  [78] 18729 68652 31203 30703 16807 39226 20485  4931 61234 81910  7598
#>  [89] 22230  1461  6380 88290 39961 34742 28490 28353 64852  1552 87529
#> [100] 78115 72558 52031 54232 10609 26586 53811 56995 89391 43516 70762
#> [111] 82799 76884 23965  8554 45051  9861 72521  6019 88050 45973 88903
#> [122] 69440 28920 41445 41711 68510 83250 36254 54912 55973 36733 86509
#> [133] 62702 88765 15477 84984 30678 87792 66997 21798 51671 66600 63347
#> [144] 61088 25835 83297 87485 75694 84813 19284 55974 51620 48549 54631
#> [155] 41848 49031 22923 61932 24340 37582 30170 64293 19714 18400 89656
#> [166]  2101 42551 41037 26205 16227 36033 31620 66067 74708 22740 62446
#> [177] 31941 35896 58968 38550 30068 85434 26839 14918  9493 11123 21093
#> [188] 61666 67858 71929 71603 21376 16019 44552 18162   743  5135 23298
#> [199] 40830 39636     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 15.20     48.1 4.68  NA POINT (433110 5338210)
#> 2   new  3.80     44.2 0.73  NA POINT (433870 5341330)
#> 3   new 13.40     93.3 3.38  NA POINT (434450 5338170)
#> 4   new 14.50     76.6 4.63  NA POINT (437490 5340850)
#> 5   new 17.70     89.0 4.69  NA POINT (434230 5338290)
#> 6   new 15.20     73.0 4.66  NA POINT (434970 5343070)
#> 7   new  9.99     81.3 2.41  NA POINT (435410 5341650)
#> 8   new 18.70     93.5 3.77  NA POINT (437230 5342530)
#> 9   new 18.00     78.5 4.25  NA POINT (436550 5341330)
#> 10  new  9.69      9.5 2.58  NA POINT (434830 5339910)
#>