@@ -11,6 +11,18 @@ test_that("can get point data from SpatialPointsDataFrame", {
11
11
expect_equal(nrow(points ), 155 )
12
12
})
13
13
14
+ test_that(" derivePolygons works with sf classes" , {
15
+ skip_if_not_installed(" sf" )
16
+
17
+ data(" meuse" , package = " sp" , envir = environment())
18
+ sp :: coordinates(meuse ) <- ~ x + y
19
+ meuse <- sf :: st_as_sf(meuse )
20
+
21
+ points <- derivePoints(meuse )
22
+ expect_named(points , c(" lng" , " lat" ))
23
+ expect_equal(nrow(points ), 155 )
24
+ })
25
+
14
26
# derivePolygons -----------------------------------------------------------
15
27
16
28
test_that(" derivePolygons normalizes polygon data across sp polygon classes" , {
@@ -55,6 +67,18 @@ test_that("derivePolygons normalizes polygon data across sp line classes", {
55
67
expect_equal(derivePolygons(slinesdf ), out )
56
68
})
57
69
70
+ test_that(" derivePolygons works with sf classes" , {
71
+ skip_if_not_installed(" sf" )
72
+
73
+ nc <- sf :: st_read(system.file(" shape/nc.shp" , package = " sf" ), quiet = TRUE )
74
+
75
+ expect_warning(
76
+ polys <- derivePolygons(nc ),
77
+ " inconsistent datum"
78
+ )
79
+
80
+ expect_length(polys , nrow(nc ))
81
+ })
58
82
59
83
# guessLatLongCols --------------------------------------------------------
60
84
ll_names <- function (lng , lat ) list (lng = lng , lat = lat )
0 commit comments