Skip to contents

Resamples a set of points with x and y coordinates by increasing the distance step by step until a given sample size is obtained.

Usage

thinning_til_n(
  xy,
  n = 30,
  distance.step = NULL
)

Arguments

xy

A data frame with columns named "x" and "y" representing geographic coordinates. Default: NULL

n

Integer, number of samples to obtain. Must be lower than nrow(xy). Default: 30

distance.step

Numeric, distance step used during the thinning iterations. If NULL, the one percent of the maximum distance among points in xy is used. Default: NULL

Value

A data frame with the same columns as xy with a row number close to n.

See also

Examples


 #loading example data
 data(plant_richness_df)

 #thinning to ~20 records
 plant_richness.thin <- thinning_til_n(
   x = plant_richness_df,
   n = 20
   )

 head(plant_richness.thin)
#>   ecoregion_id          x          y richness_species_vascular bias_area_km2
#> 1            1  -66.22004 -0.4379482                      4835     268444.41
#> 2            2  -92.07368 18.6461103                      4360      26658.41
#> 3            3 -123.99060 54.9272077                      1362     140062.77
#> 4            8  -74.19557 40.8416537                      7372      73432.58
#> 5           11  -90.03848 44.9184623                      2610     136416.82
#> 6           13 -111.09128 70.8781497                       492     985868.20
#>   bias_species_per_record climate_aridity_index_average climate_hypervolume
#> 1              0.26999949                   -1.27163039         0.022396502
#> 2              0.14566151                    0.01279434         0.521948420
#> 3              0.12185540                    0.05070049         0.030882090
#> 4              0.01940485                    0.02578303         0.001186010
#> 5              0.02390174                    0.23692385         0.001360152
#> 6              0.04898379                    0.32105481         0.061710261
#>   climate_velocity_lgm_average neighbors_count neighbors_percent_shared_edge
#> 1                     7.680623              10                     100.00000
#> 2                     7.954564              13                      56.46095
#> 3                     6.420260               8                     100.00000
#> 4                    37.967150               8                      47.89004
#> 5                    55.060137               6                      79.85805
#> 6                    23.023547               3                      21.63566
#>   human_population_density topography_elevation_average
#> 1               7.06752974                    86.807776
#> 2              42.59088614                     6.921187
#> 3               0.87119421                  1130.220919
#> 4             506.51121610                   112.525613
#> 5              45.89714710                   323.807573
#> 6               0.01520405                   167.332634
#>   landcover_herbs_percent_average fragmentation_cohesion fragmentation_division
#> 1                        16.22373               99.81169              0.9195281
#> 2                        53.90207               92.40274              0.9999953
#> 3                        42.66630               99.68820              0.9690934
#> 4                        56.48969               99.40405              0.9848386
#> 5                        77.22442               99.56957              0.9315911
#> 6                        40.31540               99.54499              0.9892298
#>   neighbors_area human_population human_footprint_average climate_bio1_average
#> 1      2005112.5       1897238.82               0.4305056            251.05816
#> 2       720242.4       1135405.42               8.3018495            261.08870
#> 3     15661626.9        122021.87               0.5687886             11.58566
#> 4      1481083.8      37194423.66              28.2622898            112.20140
#> 5      1499412.6       6261142.64              11.3612968             72.69571
#> 6      1589079.2         14989.19               0.4721781           -134.70679
#>   climate_bio15_minimum
#> 1                    13
#> 2                    25
#> 3                    17
#> 4                     5
#> 5                    17
#> 6                    28