Skip to content

Commit c6d6e16

Browse files
Correctly sample points in nndm (#161)
* Correctly sample points in nndm Fixes #160 * Refresh autoplots * Still test on Windows, just not 3.6 * Use st_bbox st_convex_hull() requires a relatively new GEOS, not on old Ubuntu
1 parent 9877514 commit c6d6e16

15 files changed

+64
-42
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ jobs:
2525
- {os: macos-latest, r: 'release'}
2626

2727
- {os: windows-latest, r: 'release'}
28-
# Use 3.6 to trigger usage of RTools35
29-
- {os: windows-latest, r: '3.6'}
3028
# use 4.1 to check with rtools40's older compiler
3129
- {os: windows-latest, r: '4.1'}
3230

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# spatialsample (development version)
22

3+
* Fixed bug where passing a polygon to `spatial_nndm_cv()` forced leave-one-out
4+
CV, rather than the intended sampling of prediction points from the polygon.
5+
36
# spatialsample 0.5.1
47

58
* `spatial_block_cv()` now adds an `expand_bbox` attribute to the resulting rset

R/spatial_nndm_cv.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ spatial_nndm_cv <- function(data, prediction_sites, ...,
126126
)
127127

128128
if (use_provided_points) {
129-
sample_points <- prediction_sites
129+
prediction_sites <- prediction_sites
130130
} else if (sample_provided_poly) {
131-
sample_points <- sf::st_sample(
131+
prediction_sites <- sf::st_sample(
132132
x = sf::st_geometry(prediction_sites),
133133
size = prediction_sample_size,
134134
...
135135
)
136136
} else {
137-
sample_points <- sf::st_sample(
137+
prediction_sites <- sf::st_sample(
138138
x = sf::st_as_sfc(sf::st_bbox(prediction_sites)),
139139
size = prediction_sample_size,
140140
...
@@ -145,9 +145,9 @@ spatial_nndm_cv <- function(data, prediction_sites, ...,
145145
# and will _sometimes_ warn instead (systematic sampling)
146146
# but will _often_ strip CRS from the returned data;
147147
# enforce here that our output prediction sites share a CRS with input data
148-
if (is.na(sf::st_crs(sample_points))) {
148+
if (is.na(sf::st_crs(prediction_sites))) {
149149
prediction_sites <- sf::st_set_crs(
150-
sample_points,
150+
prediction_sites,
151151
sf::st_crs(prediction_sites)
152152
)
153153
}

tests/testthat/_snaps/autoplot/block-split-plots.svg

Lines changed: 2 additions & 2 deletions
Loading

tests/testthat/_snaps/autoplot/buffered-llo-split-plot.svg

Lines changed: 2 additions & 2 deletions
Loading

tests/testthat/_snaps/autoplot/buffered-rsample-plot.svg

Lines changed: 5 additions & 5 deletions
Loading

tests/testthat/_snaps/autoplot/buffered-rset-plot.svg

Lines changed: 5 additions & 5 deletions
Loading

tests/testthat/_snaps/autoplot/buffered-vfold-plot.svg

Lines changed: 1 addition & 1 deletion
Loading

tests/testthat/_snaps/autoplot/buffered-vfold-split.svg

Lines changed: 5 additions & 5 deletions
Loading

tests/testthat/_snaps/autoplot/cluster-split-plots.svg

Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)