This vignette demonstrates the use of the NicEuc package on the built-in dataset synthetic_gps, designed to mimic the structure and complexity of EucFACE field layouts.

1 Key features:

Ring -> Plot -> Cell hierarchy

Stratified sampling by photosynthetic pathway (C3 vs C4)

Spatial separation using a minimum distance

Dynamic visualizations and Moran’s I for spatial autocorrelation


  library(NicEuc)
  library(sf)
#> Linking to GEOS 3.13.0, GDAL 3.8.5, PROJ 9.5.1; sf_use_s2() is TRUE
  library(spdep)
#> Loading required package: spData
#> To access larger datasets in this package, install the spDataLarge
#> package with: `install.packages('spDataLarge',
#> repos='https://nowosad.github.io/drat/', type='source')`
  library(ggplot2)
  library(leaflet)
  library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
  library(tidyr)
  library(utils)

The package includes synthetic_gps, a data frame with realistic spatial and taxonomic structure.


data("synthetic_gps", package = "NicEuc")
data("gps_ref", package = "NicEuc")

head(synthetic_gps)
#>       Ring  Plot  Cell  Latitude Longitude                    Species
#> 13   Ring1 Plot1 Cell1 -33.61768  150.7413 hydrocotyle_sibthorpioides
#> 12   Ring2 Plot1 Cell1 -33.61748  150.7415         setaria_parviflora
#> 13.1 Ring3 Plot1 Cell1 -33.61764  150.7413 hydrocotyle_sibthorpioides
#> 13.2 Ring4 Plot1 Cell1 -33.61745  150.7414 hydrocotyle_sibthorpioides
#> 3    Ring5 Plot1 Cell1 -33.61742  150.7413          centella_asiatica
#> 5    Ring6 Plot1 Cell1 -33.61778  150.7416        paspalidium_distans
#>      Photosynthetic_Pathway
#> 13                       C3
#> 12                       C4
#> 13.1                     C3
#> 13.2                     C3
#> 3                        C3
#> 5                        C4

library(dplyr)

NicEuc::gps_ref %>%
  count(Species, Photosynthetic_Pathway, sort = TRUE)
#>                       Species Photosynthetic_Pathway  n
#> 1            commelina_cyanea                     C3 12
#> 2               bidens_pilosa                     C3 11
#> 3           centella_asiatica                     C3 11
#> 4        hypoxis_hygrometrica                     C3 11
#> 5        axonopus_fissifolius                     C4 10
#> 6      fimbristylis_dichotoma                     C4  9
#> 7        hypochaeris_radicata                     C3  9
#> 8          setaria_parviflora                     C4  9
#> 9            cyperus_gracilis                     C3  8
#> 10         eragrostis_curvula                     C4  7
#> 11 hydrocotyle_sibthorpioides                     C3  7
#> 12     poranthera_microphylla                     C3  7
#> 13   arthropodium_milleflorum                     C3  6
#> 14    eragrostis_leptostachya                     C4  6
#> 15       microlaena_stipoides                     C3  6
#> 16        paspalidium_distans                     C4  6
#> 17        lomandra_filiformis                     C3  5
#> 18           cynodon_dactylon                     C4  4

2 Example


# If you want to filter sampling by specific species:

target_species <- c(
  "centella_asiatica",
  "commelina_cyanea",
  "fimbristylis_dichotoma",
  "axonopus_fissifolius"
)

3 Run generate_sampling_points()

Sample 6 points per plot, with 0.4 m minimum spacing and stratification by C3/C4.


set.seed(123)

result <- suppressWarnings(generate_sampling_points(
  gps_ref = synthetic_gps,
  samples_per_plot = 6,
  min_distance = 0.4,
  target_species = target_species,
  export_csv = FALSE
))

4 Explore Results

head(result$samples)
#> # A tibble: 6 Ă— 10
#>   Ring  Plot  Cell  Species Photosynthetic_Pathway  utm_x  utm_y Ring_Plot   lon
#>   <chr> <chr> <chr> <chr>   <chr>                   <dbl>  <dbl> <chr>     <dbl>
#> 1 Ring1 Plot1 Cell… centel… c3                     2.90e5 6.28e6 Ring1_Pl…  151.
#> 2 Ring1 Plot1 Cell… fimbri… c4                     2.90e5 6.28e6 Ring1_Pl…  151.
#> 3 Ring1 Plot1 Cell8 centel… c3                     2.90e5 6.28e6 Ring1_Pl…  151.
#> 4 Ring1 Plot1 Cell9 axonop… c4                     2.90e5 6.28e6 Ring1_Pl…  151.
#> 5 Ring1 Plot2 Cell… axonop… c4                     2.90e5 6.28e6 Ring1_Pl…  151.
#> 6 Ring1 Plot2 Cell5 commel… c3                     2.90e5 6.28e6 Ring1_Pl…  151.
#> # ℹ 1 more variable: lat <dbl>

5 ggplot2 Layout


print(result$plot)

6 Interactive Leaflet Map


result$map

7 Moran’s I Spatial Autocorrelation


result$moran_test
#> $Plot1
#> 
#>  Moran I test under randomisation
#> 
#> data:  .x$utm_x  
#> weights: lw  
#> n reduced by no-neighbour observations  
#> 
#> Moran I statistic standard deviate = 0.46889, p-value = 0.3196
#> alternative hypothesis: greater
#> sample estimates:
#> Moran I statistic       Expectation          Variance 
#>        0.03547277       -0.20000000        0.25219218 
#> 
#> 
#> $Plot2
#> [1] NA
#> 
#> $Plot3
#> [1] NA
#> 
#> $Plot4
#> [1] NA

8 Notes

Coordinates are reprojected from WGS84 to UTM Zone 56S (EPSG:32756).

Each plot is sampled independently and visualized in a faceted layout.

Sampling favors spatial separation while preserving C3/C4 balance.

9 Citation

If you use NicEuc in publications or reports, please cite the package and the author Mitra Ghotbi.