Skip to content

Commit 1b77b9c

Browse files
committed
remove dependency on packages in Suggests:
1 parent 2299f4a commit 1b77b9c

File tree

3 files changed

+31
-26
lines changed

3 files changed

+31
-26
lines changed

tests/aggregate.R

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ s = st_sf(a = 1:2, geom = st_sfc(pl1, pl2))
66
(a = aggregate(s, list(c(1,1)), mean, do_union = FALSE))
77
(a = aggregate(s, list(c(1,1)), mean, do_union = TRUE))
88
# expect_warning(st_cast(a, "POINT"))
9-
demo(meuse_sf, echo = FALSE, ask = FALSE)
10-
a = aggregate(meuse_sf, list(meuse_sf$soil), mean)
11-
attributes(a)$agr
12-
a = aggregate(meuse_sf, list(soil = meuse_sf$soil), mean)
13-
attributes(a)$agr
14-
a = aggregate(meuse_sf, list(meuse_sf$soil, meuse_sf$ffreq), mean)
15-
attributes(a)$agr
16-
a = aggregate(meuse_sf, list(soil = meuse_sf$soil, ff = meuse_sf$ffreq), mean)
17-
attributes(a)$agr
9+
if (require(sp, quietly = TRUE)) {
10+
demo(meuse_sf, echo = FALSE, ask = FALSE)
11+
a = aggregate(meuse_sf, list(meuse_sf$soil), mean)
12+
print(attributes(a)$agr)
13+
a = aggregate(meuse_sf, list(soil = meuse_sf$soil), mean)
14+
print(attributes(a)$agr)
15+
a = aggregate(meuse_sf, list(meuse_sf$soil, meuse_sf$ffreq), mean)
16+
print(attributes(a)$agr)
17+
a = aggregate(meuse_sf, list(soil = meuse_sf$soil, ff = meuse_sf$ffreq), mean)
18+
print(attributes(a)$agr)
19+
}
1820

1921
# aggregate by sf/sfc
2022
a = st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)))) * 2

tests/crs.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,17 @@ if (sf_extSoftVersion()["USE_PROJ_H"] == "true" || sf_proj_info("have_datum_file
4141
"datum files not installed"
4242
}
4343

44-
x0 = sp::CRS("+init=epsg:4326")
45-
cat(sp::wkt(x0), "\n")
46-
x = st_crs(x0)
47-
x
44+
if (require(sp, quietly = TRUE)) {
45+
x0 = sp::CRS("+init=epsg:4326")
46+
cat(sp::wkt(x0), "\n")
47+
x = st_crs(x0)
48+
print(x)
4849

49-
y0 = st_crs(4326)
50-
y0
51-
y = as(y0, "CRS")
52-
cat(sp::wkt(y), "\n")
50+
y0 = st_crs(4326)
51+
y0
52+
y = as(y0, "CRS")
53+
cat(sp::wkt(y), "\n")
54+
}
5355

5456
# https://github.com/r-spatial/sf/issues/1170
5557
g = st_as_sfc("POLYGON ((-61.66957 10.69214, -61.565 10.75728, -61.37453 10.77654, -61.40721 10.60681, -61.66957 10.69214))")

tests/dist.R

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
suppressPackageStartupMessages(library(sf))
2-
library(sp)
32
suppressPackageStartupMessages(library(units))
43

54
x = st_sfc(
@@ -19,17 +18,19 @@ st_point(c(4,0)),
1918
crs = 4326
2019
)
2120

22-
d.sf = st_distance(x, y)
23-
d.sp = spDists(as(x, "Spatial"), as(y, "Spatial"))
24-
units(d.sp) = as_units("km")
25-
round(d.sf - d.sp, 7)
21+
if (require(sp, quietly = TRUE)) {
22+
d.sf = st_distance(x, y)
23+
d.sp = spDists(as(x, "Spatial"), as(y, "Spatial"))
24+
units(d.sp) = as_units("km")
25+
print(round(d.sf - d.sp, 7))
2626

2727
#summary(unclass(d.sf) - d.sp)
2828

29-
st_crs(x) = st_crs(y) = NA
30-
d.sf = st_distance(x, y)
31-
d.sp = spDists(as(x, "Spatial"), as(y, "Spatial"))
32-
round(d.sf - d.sp, 7)
29+
st_crs(x) = st_crs(y) = NA
30+
d.sf = st_distance(x, y)
31+
d.sp = spDists(as(x, "Spatial"), as(y, "Spatial"))
32+
print(round(d.sf - d.sp, 7))
33+
}
3334

3435
# st_length:
3536
st_crs(y) = 4326

0 commit comments

Comments
 (0)