Running ‘aggregate.R’ [1s/2s]
  Comparing ‘aggregate.Rout’ to ‘aggregate.Rout.save’ ...4c4
< Linking to GEOS 3.12.1, GDAL 3.9.0, PROJ 9.4.1; sf_use_s2() is TRUE
---
> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.3.1; sf_use_s2() is TRUE
  Running ‘cast.R’ [1s/1s]
  Running ‘crs.R’ [1s/2s]
  Comparing ‘crs.Rout’ to ‘crs.Rout.save’ ...97,98d96
<         MEMBER["World Geodetic System 1984 (G2296)",
<             ID["EPSG",1383]],
139,140d136
<         MEMBER["World Geodetic System 1984 (G2296)",
<             ID["EPSG",1383]],
171d166
<         MEMBER["World Geodetic System 1984 (G2296)"],
  Running ‘dist.R’ [1s/2s]
  Comparing ‘dist.Rout’ to ‘dist.Rout.save’ ... OK
  Running ‘dplyr.R’ [1s/2s]
  Comparing ‘dplyr.Rout’ to ‘dplyr.Rout.save’ ...114a115,128
> 
> 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
> 
> [1] 4
> Warning message:
> plotting the first 10 out of 14 attributes; use max.plot = 14 to plot all 
  Running ‘empty.R’ [1s/2s]
  Comparing ‘empty.Rout’ to ‘empty.Rout.save’ ... OK
  Running ‘gdal_geom.R’ [2s/3s]
  Comparing ‘gdal_geom.Rout’ to ‘gdal_geom.Rout.save’ ... OK
  Running ‘geos.R’ [28s/37s]
  Running ‘graticule.R’ [2s/3s]
  Comparing ‘graticule.Rout’ to ‘graticule.Rout.save’ ... OK
  Running ‘grid.R’ [2s/2s]
  Comparing ‘grid.Rout’ to ‘grid.Rout.save’ ... OK
  Running ‘maps.R’ [2s/3s]
  Comparing ‘maps.Rout’ to ‘maps.Rout.save’ ... OK
  Running ‘plot.R’ [1s/1s]
  Comparing ‘plot.Rout’ to ‘plot.Rout.save’ ...124a125,136
> 
> 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
> 
> There were 13 warnings (use warnings() to see them)
  Running ‘read.R’ [2s/3s]
  Running ‘roundtrip.R’ [2s/3s]
  Comparing ‘roundtrip.Rout’ to ‘roundtrip.Rout.save’ ... OK
  Running ‘s2.R’ [2s/3s]
  Comparing ‘s2.Rout’ to ‘s2.Rout.save’ ... OK
  Running ‘sample.R’ [1s/2s]
  Comparing ‘sample.Rout’ to ‘sample.Rout.save’ ... OK
  Running ‘sfc.R’ [12s/16s]
  Comparing ‘sfc.Rout’ to ‘sfc.Rout.save’ ...144a145,150
> Simple feature collection with 2 features and 1 field
> Active geometry column: geom
> Geometry type: POINT
> Dimension:     XY
> Bounding box:  xmin: 0 ymin: 0 xmax: 1 ymax: 1
> CRS:           NA
329c335
< "3.12.1"  "3.9.0"  "9.4.1" 
---
> "3.12.1"  "3.8.4"  "9.3.1" 
540a547,576
> 
> Attaching package: 'dplyr'
> 
> The following object is masked from 'package:testthat':
> 
>     matches
> 
> The following objects are masked from 'package:stats':
> 
>     filter, lag
> 
> The following objects are masked from 'package:base':
> 
>     intersect, setdiff, setequal, union
> 
> Joining with `by = join_by(b)`
> Joining with `by = join_by(b)`
> Joining with `by = join_by(b)`
> Joining with `by = join_by(b)`
> Joining with `by = join_by(b)`
> Joining with `by = join_by(b)`
> Simple feature collection with 3 features and 4 fields
> Geometry type: POINT
> Dimension:     XY
> Bounding box:  xmin: 0 ymin: 0 xmax: 2 ymax: 2
> CRS:           NA
>   a b    x geometry.y  geometry.x
> 1 1 5    b          1 POINT (0 0)
> 2 2 6    c          1 POINT (1 1)
> 3 3 7 <NA>         NA POINT (2 2)
731a768,775
> New names:
> • `AREA` -> `AREA...1`
> • `PERIMETER` -> `PERIMETER...2`
> • `CNTY_` -> `CNTY_...3`
> • `AREA` -> `AREA...16`
> • `PERIMETER` -> `PERIMETER...17`
> • `CNTY_` -> `CNTY_...18`
> [1] "sf"         "data.frame"
771a816,822
> 
> Attaching package: 'raster'
> 
> The following object is masked from 'package:dplyr':
> 
>     select
> 
  Running ‘sfg.R’ [1s/1s]
  Comparing ‘sfg.Rout’ to ‘sfg.Rout.save’ ... OK
  Running ‘spatstat.R’ [3s/4s]
  Running ‘stars.R’ [5s/7s]
  Comparing ‘stars.Rout’ to ‘stars.Rout.save’ ... OK
  Running ‘testthat.R’ [0s/1s]
  Running ‘units.R’ [1s/2s]
  Comparing ‘units.Rout’ to ‘units.Rout.save’ ... OK
  Running ‘wkb.R’ [1s/2s]
  Comparing ‘wkb.Rout’ to ‘wkb.Rout.save’ ... OK
Running the tests in ‘tests/cast.R’ failed.
Complete output:
  > suppressPackageStartupMessages(library(sf))
  > library(testthat)
  Error in library(testthat) : there is no package called 'testthat'
  Execution halted
Running the tests in ‘tests/geos.R’ failed.
Complete output:
  > suppressPackageStartupMessages(library(sf))
  > # nc = st_read(system.file("gpkg/nc.gpkg", package="sf"))
  > nc = st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
  > nc_checked = st_transform(nc, 32119, check = TRUE)
  > ncm = st_transform(nc, 32119)
  > 
  > x = st_transform(nc[1:10,], 32119)
  > st_distance(x)
  Units: [m]
             [,1]      [,2]      [,3]      [,4]      [,5]      [,6]      [,7]
   [1,]      0.00      0.00  25651.99 440561.48 299772.34 361529.73 419671.66
   [2,]      0.00      0.00      0.00 409429.44 268945.05 332590.52 388545.58
   [3,]  25651.99      0.00      0.00 367556.52 227018.38 290298.04 346669.14
   [4,] 440561.48 409429.44 367556.52      0.00  67226.86  45537.62      0.00
   [5,] 299772.34 268945.05 227018.38  67226.86      0.00      0.00  46527.56
   [6,] 361529.73 332590.52 290298.04  45537.62      0.00      0.00  30213.17
   [7,] 419671.66 388545.58 346669.14      0.00  46527.56  30213.17      0.00
   [8,] 384593.29 354295.06 312351.76  16130.19  11926.86      0.00      0.00
   [9,] 262353.97 231217.73 189310.73 140455.97      0.00  64606.27 119564.00
  [10,]  71138.53  41943.71      0.00 330752.58 190183.42 252373.26 309863.33
             [,8]      [,9]     [,10]
   [1,] 384593.29 262353.97  71138.53
   [2,] 354295.06 231217.73  41943.71
   [3,] 312351.76 189310.73      0.00
   [4,]  16130.19 140455.97 330752.58
   [5,]  11926.86      0.00 190183.42
   [6,]      0.00  64606.27 252373.26
   [7,]      0.00 119564.00 309863.33
   [8,]      0.00  85533.33 275391.07
   [9,]  85533.33      0.00 152489.45
  [10,] 275391.07 152489.45      0.00
  > 
  > st_is_valid(nc)
    [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   [16] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   [31] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   [46] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   [61] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   [76] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
   [91] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
  > 
  > st_is_empty(st_sfc(st_point(), st_linestring()))
  [1] TRUE TRUE
  > 
  > ops = c("intersects", #"disjoint", 
  + "touches", "crosses", "within", "contains", "overlaps", "equals", "covers", "covered_by", "equals_exact")
  > for (op in ops) {
  + 	x = sf:::st_geos_binop(op, ncm[1:50,], ncm[51:100,], 0, NA_character_, FALSE)
  + 	x = sf:::st_geos_binop(op, ncm[1:50,], ncm[51:100,], 0, NA_character_, TRUE)
  + }
  > 
  > ops = c("intersects", #"disjoint", 
  + "touches", "crosses", "within", "contains", "overlaps", "covers", "covered_by")
  > df = data.frame(ops = ops)
  > df$equal = NA
  > for (op in ops)
  + 	df[df$ops == op, "equal"] = identical(
  + 		sf:::st_geos_binop(op, ncm[1:50,], ncm[51:100,], 0, NA_character_, TRUE, FALSE),
  + 		sf:::st_geos_binop(op, ncm[1:50,], ncm[51:100,], 0, NA_character_, TRUE,  TRUE)
  + 	)
  > df
           ops equal
  1 intersects  TRUE
  2    touches  TRUE
  3    crosses  TRUE
  4     within  TRUE
  5   contains  TRUE
  6   overlaps  TRUE
  7     covers  TRUE
  8 covered_by  TRUE
  > 
  > st_contains_properly(ncm[1:3,], ncm[1:3])
  Sparse geometry binary predicate list of length 3, where the predicate
  was `contains_properly'
   1: (empty)
   2: (empty)
   3: (empty)
  > 
  > st_combine(nc)
  Geometry set for 1 feature 
  Geometry type: MULTIPOLYGON
  Dimension:     XY
  Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
  Geodetic CRS:  NAD27
  MULTIPOLYGON (((-81.47276 36.23436, -81.54084 3...
  > 
  > st_dimension(st_sfc(st_point(0:1), st_linestring(rbind(c(0,0),c(1,1))), 
  + 	st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))))))
  [1] 0 1 2
  > 
  > ncbb = st_as_sfc(st_bbox(nc))
  > g = st_make_grid(ncbb)
  > x = st_intersection(nc, g)
  Warning message:
  attribute variables are assumed to be spatially constant throughout all geometries 
  > x = st_intersection(g, nc)
  > 
  > ls = st_sfc(st_linestring(rbind(c(0,0),c(0,1))),
  + st_linestring(rbind(c(0,0),c(10,0))))
  > 
  > suppressWarnings(RNGversion("3.5.3"))
  > set.seed(13531)
  > 
  > st_line_sample(ls, density = 1, type = "random")
  Geometry set for 2 features 
  Geometry type: MULTIPOINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 6.880179 ymax: 0.8878369
  CRS:           NA
  MULTIPOINT ((0 0.8878369))
  MULTIPOINT ((0.2986488 0), (2.48417 0), (2.5678...
  > 
  > g = st_make_grid(ncbb, n = c(20,10))
  > 
  > a1 = st_interpolate_aw(nc["BIR74"], g, FALSE)
  Warning message:
  In st_interpolate_aw.sf(nc["BIR74"], g, FALSE) :
    st_interpolate_aw assumes attributes are constant or uniform over areas of x
  > sum(a1$BIR74) / sum(nc$BIR74) # not close to one: property is assumed spatially intensive
  [1] 1.436123
  > a2 = st_interpolate_aw(nc["BIR74"], g, extensive = TRUE)
  Warning message:
  In st_interpolate_aw.sf(nc["BIR74"], g, extensive = TRUE) :
    st_interpolate_aw assumes attributes are constant or uniform over areas of x
  > sum(a2$BIR74) / sum(nc$BIR74)
  [1] 1
  > 
  > # missing x:
  > g = st_make_grid(offset = c(0,0), cellsize = c(1,1), n = c(10,10))
  > g = st_make_grid(what = "centers")
  > length(g)
  [1] 648
  > g = st_make_grid(what = "corners")
  > length(g)
  [1] 703
  > 
  > g1 = st_make_grid(ncbb, 0.1, what = "polygons", square = FALSE)
  > g2 = st_make_grid(ncbb, 0.1, what = "points", square = FALSE)
  > 
  > # st_line_merge:
  > mls = st_multilinestring(list(rbind(c(0,0), c(1,1)), rbind(c(2,0), c(1,1))))
  > st_line_merge(mls)
  LINESTRING (0 0, 1 1, 2 0)
  > 
  > if (isTRUE(try(compareVersion(sf_extSoftVersion()["GEOS"], "3.5.0") > -1, silent = TRUE))) {
  +  # voronoi:
  +  set.seed(1)
  +  x = st_multipoint(matrix(runif(10),,2))
  +  box = st_polygon(list(rbind(c(0,0),c(1,0),c(1,1),c(0,1),c(0,0))))
  +  v = st_sfc(st_voronoi(x, st_sfc(box)))
  +  plot(v, col = 0, border = 1, axes = TRUE)
  +  plot(box, add = TRUE, col = 0, border = 1) # a larger box is returned, as documented
  +  plot(x, add = TRUE, col = 'red', cex=2, pch=16)
  +  plot(st_intersection(st_cast(v), box)) # clip to smaller box
  +  plot(x, add = TRUE, col = 'red', cex=2, pch=16)
  + 
  +  v = st_voronoi(x)
  +  print(class(v))
  +  v = st_sfc(st_voronoi(st_sfc(x)))
  +  print(class(v))
  +  v = st_voronoi(st_sf(a = 1, geom = st_sfc(x)))
  +  print(class(v))
  + }
  [1] "XY"                 "GEOMETRYCOLLECTION" "sfg"               
  [1] "sfc_GEOMETRYCOLLECTION" "sfc"                   
  [1] "sf"         "data.frame"
  > 
  > i = st_intersects(ncm, ncm[1:88,])
  > all.equal(i, t(t(i)))
  [1] TRUE
  > 
  > # check use of pattern in st_relate:
  > sfc = st_as_sfc(st_bbox(st_sfc(st_point(c(0,0)), st_point(c(3,3)))))
  > grd = st_make_grid(sfc, n = c(3,3))
  > st_intersects(grd)
  Sparse geometry binary predicate list of length 9, where the predicate
  was `intersects'
   1: 1, 2, 4, 5
   2: 1, 2, 3, 4, 5, 6
   3: 2, 3, 5, 6
   4: 1, 2, 4, 5, 7, 8
   5: 1, 2, 3, 4, 5, 6, 7, 8, 9
   6: 2, 3, 5, 6, 8, 9
   7: 4, 5, 7, 8
   8: 4, 5, 6, 7, 8, 9
   9: 5, 6, 8, 9
  > st_relate(grd, pattern = "****1****")
  Sparse geometry binary predicate list of length 9, where the predicate
  was `relate_pattern'
   1: 1, 2, 4
   2: 1, 2, 3, 5
   3: 2, 3, 6
   4: 1, 4, 5, 7
   5: 2, 4, 5, 6, 8
   6: 3, 5, 6, 9
   7: 4, 7, 8
   8: 5, 7, 8, 9
   9: 6, 8, 9
  > st_relate(grd, pattern = "****0****")
  Sparse geometry binary predicate list of length 9, where the predicate
  was `relate_pattern'
   1: 5
   2: 4, 6
   3: 5
   4: 2, 8
   5: 1, 3, 7, 9
   6: 2, 8
   7: 5
   8: 4, 6
   9: 5
  > st_rook = function(a, b = a, ...) st_relate(a, b, pattern = "F***1****", ...)
  > st_rook(grd, sparse = FALSE)
         [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9]
   [1,] FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE FALSE
   [2,]  TRUE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE FALSE
   [3,] FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE FALSE FALSE
   [4,]  TRUE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE
   [5,] FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE  TRUE FALSE
   [6,] FALSE FALSE  TRUE FALSE  TRUE FALSE FALSE FALSE  TRUE
   [7,] FALSE FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE
   [8,] FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE  TRUE
   [9,] FALSE FALSE FALSE FALSE FALSE  TRUE FALSE  TRUE FALSE
  > 
  > #if (Sys.getenv("USER") %in% c("edzer", "travis")) { # memory leaks:
  >   try(st_relate(st_point(), st_point(), pattern = "FF*FF****")) # error: use st_disjoint
  Error : use st_disjoint for this pattern
  > #}
  > 
  > a = st_is_within_distance(nc[c(1:3,20),], nc[1:3,], 100000, sparse = FALSE)
  > b = st_is_within_distance(nc[c(1:3,20),], nc[1:3,], units::set_units(100000, m), sparse = FALSE)
  > all.equal(a, b)
  [1] TRUE
  > x = st_is_within_distance(nc[1:3,], nc[1:5,], 100000)
  > y = st_is_within_distance(nc[1:3,], nc[1:5,], units::set_units(100, km))
  > all.equal(x, y)
  [1] TRUE
  > 
  > nc_3857 = st_transform(nc, 3857)
  > a = st_is_within_distance(nc_3857[c(1:3,20),], nc_3857[1:3,], 100000, sparse = FALSE)
  > b = st_is_within_distance(nc_3857[c(1:3,20),], nc_3857[1:3,], units::set_units(100000, m), sparse = FALSE)
  > all.equal(a, b)
  [1] TRUE
  > x = st_is_within_distance(nc_3857, nc_3857, 100000)
  > y = st_is_within_distance(nc_3857, nc_3857, units::set_units(100, km))
  > all.equal(x, y)
  [1] TRUE
  > 
  > pe = st_sfc(st_point())
  > p = st_sfc(st_point(c(0,0)), st_point(c(0,1)), st_point(c(0,2)))
  > st_distance(p, p)
       [,1] [,2] [,3]
  [1,]    0    1    2
  [2,]    1    0    1
  [3,]    2    1    0
  > st_distance(p, pe)
       [,1]
  [1,]   NA
  [2,]   NA
  [3,]   NA
  > st_distance(p, p, by_element = TRUE)
  [1] 0 0 0
  > st_crs(p) = 4326
  > st_distance(p, p[c(2,3,1)], by_element = TRUE)
  Units: [m]
  [1] 111195.1 111195.1 222390.2
  > p = st_transform(p, 3587)
  > st_distance(p, p[c(2,3,1)], by_element = TRUE)
  Units: [m]
  [1] 144589.5 142873.3 287462.8
  > 
  > # from https://github.com/r-spatial/sf/issues/458 :
  > pts <- st_sfc(st_point(c(.5,.5)), st_point(c(1.5, 1.5)), st_point(c(2.5, 2.5)))
  > pol <- st_polygon(list(rbind(c(0,0), c(2,0), c(2,2), c(0,2), c(0,0))))
  > pol_df <- data.frame(id = 1) 
  > st_geometry(pol_df) <- st_sfc(pol)
  > st_intersects(pts, pol_df[pol_df$id == 2,]) # with empty sf/sfc
  Sparse geometry binary predicate list of length 3, where the predicate
  was `intersects'
   1: (empty)
   2: (empty)
   3: (empty)
  > st_intersects(pts, pol_df[pol_df$id == 2,], sparse = FALSE) # with empty sf/sfc
      
  [1,]
  [2,]
  [3,]
  > 
  > # st_node
  > l = st_linestring(rbind(c(0,0), c(1,1), c(0,1), c(1,0), c(0,0)))
  > st_node(l)
  MULTILINESTRING ((0 0, 0.5 0.5), (0.5 0.5, 1 1, 0 1, 0.5 0.5), (0.5 0.5, 1 0, 0 0))
  > st_node(st_sfc(l))
  Geometry set for 1 feature 
  Geometry type: MULTILINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 1 ymax: 1
  CRS:           NA
  MULTILINESTRING ((0 0, 0.5 0.5), (0.5 0.5, 1 1,...
  > st_node(st_sf(a = 1, st_sfc(l)))
  Simple feature collection with 1 feature and 1 field
  Geometry type: MULTILINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 1 ymax: 1
  CRS:           NA
    a                      st_sfc.l.
  1 1 MULTILINESTRING ((0 0, 0.5 ...
  > 
  > # print.sgbp:
  > (lst = st_disjoint(nc, nc))
  Sparse geometry binary predicate list of length 100, where the
  predicate was `disjoint'
  first 10 elements:
   1: 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ...
   2: 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ...
   3: 1, 4, 5, 6, 7, 8, 9, 11, 12, 13, ...
   4: 1, 2, 3, 5, 6, 8, 9, 10, 11, 12, ...
   5: 1, 2, 3, 4, 7, 8, 10, 11, 12, 13, ...
   6: 1, 2, 3, 4, 7, 9, 10, 11, 12, 13, ...
   7: 1, 2, 3, 5, 6, 9, 10, 11, 12, 13, ...
   8: 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, ...
   9: 1, 2, 3, 4, 6, 7, 8, 10, 11, 12, ...
   10: 1, 2, 4, 5, 6, 7, 8, 9, 11, 13, ...
  > # dim.sgbp:
  > dim(lst)
  [1] 100 100
  > # as.matrix.sgbp:
  > as.matrix(lst)[1:5, 1:5]
        [,1]  [,2]  [,3]  [,4]  [,5]
  [1,] FALSE FALSE  TRUE  TRUE  TRUE
  [2,] FALSE FALSE FALSE  TRUE  TRUE
  [3,]  TRUE FALSE FALSE  TRUE  TRUE
  [4,]  TRUE  TRUE  TRUE FALSE  TRUE
  [5,]  TRUE  TRUE  TRUE  TRUE FALSE
  > # negate:
  > !lst
  Sparse geometry binary predicate list of length 100, where the
  predicate was `!disjoint'
  first 10 elements:
   1: 1, 2, 18, 19
   2: 1, 2, 3, 18
   3: 2, 3, 10, 18, 23, 25
   4: 4, 7, 56
   5: 5, 6, 9, 16, 28
   6: 5, 6, 8, 28
   7: 4, 7, 8, 17
   8: 6, 7, 8, 17, 20, 21
   9: 5, 9, 15, 16, 24, 31
   10: 3, 10, 12, 25, 26
  > # as.data.frame:
  > head(as.data.frame(lst), 10)
     row.id col.id
  1       1      3
  2       1      4
  3       1      5
  4       1      6
  5       1      7
  6       1      8
  7       1      9
  8       1     10
  9       1     11
  10      1     12
  > 
  > # snap:
  > nc1 = st_transform(nc, 32119)
  > g = st_make_grid(nc1, c(5000,5000), what = "centers")
  > s = st_snap(nc1[1:3,], g, 2501*sqrt(2))
  > sfg = st_snap(st_geometry(nc1)[[1]], g, 2501*sqrt(2))
  > sfg = st_snap(st_geometry(nc1)[[1]], st_combine(g), 2501*sqrt(2))
  > 
  > # Hausdorff distance: http://geos.refractions.net/ro/doxygen_docs/html/classgeos_1_1algorithm_1_1distance_1_1DiscreteHausdorffDistance.html
  > A = st_as_sfc("LINESTRING (0 0, 100 0, 10 100, 10 100)")
  > B = st_as_sfc("LINESTRING (0 100, 0 10, 80 10)")
  > st_distance(c(A,B))
           [,1]     [,2]
  [1,] 0.000000 8.176236
  [2,] 8.176236 0.000000
  > st_distance(c(A,B), which = "Hausdorff")
           [,1]     [,2]
  [1,]  0.00000 22.36068
  [2,] 22.36068  0.00000
  > st_distance(c(A,B), which = "Hausdorff", par = 0.001)
               [,1]         [,2]
  [1,] 2.929643e-14 4.789000e+01
  [2,] 4.789000e+01 2.131628e-14
  > LE = st_as_sfc("LINESTRING EMPTY")
  > st_distance(c(A, LE), which = "Hausdorff", par = 0.001)
               [,1] [,2]
  [1,] 2.929643e-14   NA
  [2,]           NA   NA
  > 
  > # one-argument st_intersection and st_difference:
  > set.seed(131)
  > m = rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))
  > p = st_polygon(list(m))
  > n = 100
  > l = vector("list", n)
  > for (i in 1:n)
  +    l[[i]] = p + 10 * runif(2)
  > s = st_sfc(l)
  > plot(s, col = sf.colors(categorical = TRUE, alpha = .5))
  > d = st_difference(s) # sequential differences: s1, s2-s1, s3-s2-s1, ...
  > plot(d, col = sf.colors(categorical = TRUE, alpha = .5))
  > i = st_intersection(s) # all intersections
  > plot(i, col = sf.colors(categorical = TRUE, alpha = .5))
  > summary(lengths(st_overlaps(s, s)))
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
     0.00    2.00    3.50    3.66    5.00    8.00 
  > summary(lengths(st_overlaps(d, d)))
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
        0       0       0       0       0       0 
  > summary(lengths(st_overlaps(i, i)))
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
        0       0       0       0       0       0 
  > 
  > sf = st_sf(s)
  > i = st_intersection(sf) # all intersections
  > plot(i["n.overlaps"])
  > summary(i$n.overlaps - lengths(i$origins))
     Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
        0       0       0       0       0       0 
  > 
  > # st_nearest_points:
  > pt1 = st_point(c(.1,.1))
  > pt2 = st_point(c(.9,.9))
  > b1 = st_buffer(pt1, 0.1)
  > b2 = st_buffer(pt2, 0.1)
  > plot(b1, xlim = c(0,1), ylim = c(0,1))
  > plot(b2, add = TRUE)
  > (ls0 = try(st_nearest_points(b1, b2))) # sfg
  Geometry set for 1 feature 
  Geometry type: LINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0.1707107 ymin: 0.1707107 xmax: 0.8292893 ymax: 0.8292893
  CRS:           NA
  LINESTRING (0.1707107 0.1707107, 0.8292893 0.82...
  > (ls = try(st_nearest_points(st_sfc(b1), st_sfc(b2)))) # sfc
  Geometry set for 1 feature 
  Geometry type: LINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0.1707107 ymin: 0.1707107 xmax: 0.8292893 ymax: 0.8292893
  CRS:           NA
  LINESTRING (0.1707107 0.1707107, 0.8292893 0.82...
  > (ls = try(st_nearest_points(st_sfc(b1), st_sfc(b2), pairwise = TRUE))) # sfc
  Geometry set for 1 feature 
  Geometry type: LINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0.1707107 ymin: 0.1707107 xmax: 0.8292893 ymax: 0.8292893
  CRS:           NA
  LINESTRING (0.1707107 0.1707107, 0.8292893 0.82...
  > identical(ls0, ls)
  [1] TRUE
  > # plot(ls, add = TRUE, col = 'red')
  > 
  > nc = read_sf(system.file("gpkg/nc.gpkg", package="sf"))
  Error in process_cpl_read_ogr(x, quiet, check_ring_dir = check_ring_dir,  : 
    package tibble not available: install first?
  Calls: read_sf ... st_read -> st_read.character -> process_cpl_read_ogr
  Execution halted
Running the tests in ‘tests/read.R’ failed.
Complete output:
  > Sys.setenv(TZ="UTC")
  > suppressPackageStartupMessages(library(sf))
  > if ("GPKG" %in% st_drivers()$name) {
  + 	tst = st_read(system.file("gpkg/nc.gpkg", package="sf"), "nc.gpkg", crs = 4267, quiet = TRUE)
  + 	tst = st_read(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE) # default layer name
  + }
  > 
  > tst = st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE) # no layer specified
  > 
  > # data from https://github.com/edzer/sfr/issues/6
  > tst = st_read(system.file("shape/storms_xyz.shp", package="sf"), quiet = TRUE)
  > class(st_geometry(tst))
  [1] "sfc_LINESTRING" "sfc"           
  > class(st_geometry(tst)[[1]])
  [1] "XYZ"        "LINESTRING" "sfg"       
  > tst = st_read(system.file("shape/storms_xyzm.shp", package="sf"), quiet = TRUE)
  > class(st_geometry(tst))
  [1] "sfc_LINESTRING" "sfc"           
  > class(st_geometry(tst)[[1]])
  [1] "XYM"        "LINESTRING" "sfg"       
  > tst = st_read(system.file("shape/storms_xyz_feature.shp", package="sf"), quiet = TRUE)
  > class(st_geometry(tst))
  [1] "sfc_LINESTRING" "sfc"           
  > class(st_geometry(tst)[[1]])
  [1] "XYZ"        "LINESTRING" "sfg"       
  > tst = st_read(system.file("shape/storms_xyzm_feature.shp", package="sf"), quiet = TRUE)
  > class(st_geometry(tst))
  [1] "sfc_LINESTRING" "sfc"           
  > class(st_geometry(tst)[[1]])
  [1] "XYM"        "LINESTRING" "sfg"       
  > 
  > if ("GPKG" %in% st_drivers()$name) { # read Int64
  +     print(st_read(system.file("gpkg/tl.gpkg", package="sf"), quiet = TRUE)$AWATER)
  +     print(st_read(system.file("gpkg/tl.gpkg", package="sf"), quiet = TRUE, int64_as_string = TRUE)$AWATER)
  + }
  [1] 1028678842
  [1] "1028678842"
  > 
  > # see https://github.com/edzer/sfr/issues/45 :
  > if ("OSM" %in% st_drivers()$name && Sys.info()['sysname'] != "Darwin") {
  + 	osm = system.file("osm/overpass.osm", package="sf")
  + 	osm_l = st_layers(osm)
  + 	osm_lc = suppressWarnings(st_layers(osm, do_count = TRUE))
  + 	osm_r = suppressWarnings(st_read(osm, "multipolygons", quiet = TRUE))
  + }
  > 
  > # layer opening option:
  > st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE,
  + 	options = c("ADJUST_TYPE=YES", "ENCODING=CPL_ENC_UTF8"))
  Simple feature collection with 100 features and 14 fields
  Geometry type: MULTIPOLYGON
  Dimension:     XY
  Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
  Geodetic CRS:  NAD27
  First 10 features:
      AREA PERIMETER CNTY_ CNTY_ID        NAME  FIPS FIPSNO CRESS_ID BIR74 SID74
  1  0.114     1.442  1825    1825        Ashe 37009  37009        5  1091     1
  2  0.061     1.231  1827    1827   Alleghany 37005  37005        3   487     0
  3  0.143     1.630  1828    1828       Surry 37171  37171       86  3188     5
  4  0.070     2.968  1831    1831   Currituck 37053  37053       27   508     1
  5  0.153     2.206  1832    1832 Northampton 37131  37131       66  1421     9
  6  0.097     1.670  1833    1833    Hertford 37091  37091       46  1452     7
  7  0.062     1.547  1834    1834      Camden 37029  37029       15   286     0
  8  0.091     1.284  1835    1835       Gates 37073  37073       37   420     0
  9  0.118     1.421  1836    1836      Warren 37185  37185       93   968     4
  10 0.124     1.428  1837    1837      Stokes 37169  37169       85  1612     1
     NWBIR74 BIR79 SID79 NWBIR79                       geometry
  1       10  1364     0      19 MULTIPOLYGON (((-81.47276 3...
  2       10   542     3      12 MULTIPOLYGON (((-81.23989 3...
  3      208  3616     6     260 MULTIPOLYGON (((-80.45634 3...
  4      123   830     2     145 MULTIPOLYGON (((-76.00897 3...
  5     1066  1606     3    1197 MULTIPOLYGON (((-77.21767 3...
  6      954  1838     5    1237 MULTIPOLYGON (((-76.74506 3...
  7      115   350     2     139 MULTIPOLYGON (((-76.00897 3...
  8      254   594     2     371 MULTIPOLYGON (((-76.56251 3...
  9      748  1190     2     844 MULTIPOLYGON (((-78.30876 3...
  10     160  2038     5     176 MULTIPOLYGON (((-80.02567 3...
  > 
  > x <- st_sf(a = 1:2, geom = st_sfc(st_point(0:1), st_multipoint(matrix(1:4,2,2))))
  > 
  > try(st_layers("foo")) # cannot open datasource
  Cannot open data source foo
  Error : Open failed.
  
  > try(st_read("foo")) # cannot open datasource
  Error : Cannot open "foo"; The file doesn't seem to exist.
  > try(st_read("x.gpkg", "xyz")) # cannot open layer
  Error : Cannot open "x.gpkg"; The file doesn't seem to exist.
  > try(st_write(c("foo", "bar")))
  Error in UseMethod("st_write") : 
    no applicable method for 'st_write' applied to an object of class "character"
  > try(st_write(x, c("foo", "bar")))
  writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
  Error in guess_driver(dns) : length(dsn) == 1 is not TRUE
  > try(st_write(x, "foo", driver = "foo"))
  writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
  driver `foo' not available.
  Error : Driver not available.
  
  > if (Sys.getenv("USER") == "travis") {
  + 	try(st_write(x, "/x", driver = "ESRI Shapefile"))
  + 	st_write(x, "xxx.gpkg")
  + 	st_write(x, "xxx.gpkg", append = TRUE, quiet = FALSE) # appends to layer
  + 	y <- st_sf(b = 1:2, geom = st_sfc(st_point(0:1), st_multipoint(matrix(1:4,2,2))))
  + 	try(st_write(y, "xxx.gpkg"))
  + }
  > 
  > geom = st_sfc(st_point(0:1), st_multipoint(matrix(1:4,2,2)))
  > st_write(geom, "geom.gpkg")
  writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
  Writing layer `geom' to data source `geom.gpkg' using driver `GPKG'
  Writing 2 features with 0 fields and geometry type Unknown (any).
  > st_write(geom, "geom1.gpkg", layer = "foo")
  writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
  Writing layer `foo' to data source `geom1.gpkg' using driver `GPKG'
  Writing 2 features with 0 fields and geometry type Unknown (any).
  > 
  > df <- data.frame(
  +     a = c(0, 1, NA, -Inf, Inf),
  +     b = c("a", "b", NA, "c", ""),
  +     c = c(as.Date("2001-01-01"),
  +           as.Date(c(NA, -99, 0, 1), origin = "1970-01-01")),
  +     d = c(as.POSIXct("2001-01-01"),
  +           as.POSIXct(c(NA, -99, 0, 1), origin = "1970-01-01")),
  +     x = 1:5,
  +     y = 1:5)
  > 
  > x  = st_as_sf(df, coords = c("x", "y"))
  > 
  > if ("GPKG" %in% st_drivers()$name) {
  +  st_write(x, "x2.gpkg", quiet = TRUE)
  +  y = st_read("x2.gpkg", quiet = TRUE)
  +  print(y)
  + }
  writing: substituting ENGCRS["Undefined Cartesian SRS with unknown unit"] for missing CRS
  Simple feature collection with 5 features and 4 fields
  Geometry type: POINT
  Dimension:     XY
  Bounding box:  xmin: 1 ymin: 1 xmax: 5 ymax: 5
  Projected CRS: Undefined Cartesian SRS with unknown unit
       a    b          c                   d        geom
  1    0    a 2001-01-01 2001-01-01 00:00:00 POINT (1 1)
  2    1    b       <NA>                <NA> POINT (2 2)
  3   NA <NA> 1969-09-24 1969-12-31 23:58:21 POINT (3 3)
  4 -Inf    c 1970-01-01 1970-01-01 00:00:00 POINT (4 4)
  5  Inf      1970-01-02 1970-01-01 00:00:01 POINT (5 5)
  > 
  > if ("SQLite" %in% st_drivers()$name && require(RSQLite)) {
  + 	db = system.file("sqlite/meuse.sqlite", package = "sf")
  + 	dbcon <- dbConnect(dbDriver("SQLite"), db)
  + 	m = dbReadTable(dbcon, "meuse.sqlite")
  + 	m$GEOMETRY = st_as_sfc(m$GEOMETRY, spatialite = FALSE) # ISO wkb
  + 	print(st_sf(m), n = 3)
  + 	# or:
  + 	(s = st_read(dbcon, "meuse.sqlite"))[1:3,]
  + 	dbDisconnect(dbcon)
  + 
  + 	db = system.file("sqlite/nc.sqlite", package = "sf")
  + 	dbcon <- dbConnect(dbDriver("SQLite"), db)
  + 	m = dbReadTable(dbcon, "nc.sqlite")
  + 	m$GEOMETRY = st_as_sfc(m$GEOMETRY, spatialite = FALSE) # ISO wkb
  + 	print(st_sf(m), n = 3)
  + 	dbDisconnect(dbcon)
  + 
  + 	db = system.file("sqlite/b.sqlite", package = "sf") # has an INT8 field
  + 	b = st_read(db, quiet = TRUE)
  + 	print(b)
  + 	b = st_read(db, int64_as_string = TRUE, quiet = TRUE)
  + 	print(b)
  + 
  + 	if (.Platform$endian == "little") {
  + 	  db = system.file("sqlite/test3.sqlite", package = "sf")
  + 	  dbcon <- dbConnect(dbDriver("SQLite"), db)
  + 	  m = dbReadTable(dbcon, "HighWays")
  + 	  m$Geometry = st_as_sfc(m$Geometry, spatialite = TRUE) # spatialite wkb
  + 	  print(st_sf(m), n = 1)
  + 	  m = dbReadTable(dbcon, "Towns")
  + 	  m$Geometry = st_as_sfc(m$Geometry, spatialite = TRUE) # spatialite wkb
  + 	  print(st_sf(m), n = 1)
  + 	  m = dbReadTable(dbcon, "Regions")
  + 	  m$Geometry = st_as_sfc(m$Geometry, spatialite = TRUE) # spatialite wkb
  + 	  print(st_sf(m), n = 1)
  + 	}
  + }
  Loading required package: RSQLite
  Warning message:
  In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
    there is no package called 'RSQLite'
  > 
  > csv = system.file("csv/pt.csv", package = "sf")
  > identical(st_read(quiet = TRUE, csv, options = "AUTODETECT_TYPE=Yes")$Int64[3], NA_real_)
  [1] TRUE
  > identical(st_read(quiet = TRUE, csv, int64_as_string = TRUE, stringsAsFactors = FALSE,
  + 	options = "AUTODETECT_TYPE=Yes")$Int64[3], NA_character_)
  [1] TRUE
  > identical(st_read(quiet = TRUE, csv, options = "AUTODETECT_TYPE=Yes")$Int32[3], NA_integer_)
  [1] TRUE
  > 
  > if ("GML" %in% st_drivers()$name) {
  +   gml = system.file("gml/fmi_test.gml", package = "sf")
  +   print(dim(st_read(gml, quiet = TRUE, use_stream = FALSE)))
  +   gml = system.file("gml/20170930_OB_530964_UKSH.xml.gz", package = "sf")
  +   print(dim(st_read(gml, layer = "Parcely", quiet = TRUE, use_stream = FALSE)))
  +   print(dim(st_read(gml, layer = "Parcely", int64_as_string=TRUE, quiet = TRUE, use_stream = FALSE)))
  + }
  [1] 22 11
  [1] 644  25
  [1] 644  25
  Warning messages:
  1: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
    GDAL Message 1: Field with same name (identifier) already exists in (PointTimeSeriesObservation). Skipping newer ones
  2: In CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  :
    GDAL Message 1: Field with same name (name) already exists in (PointTimeSeriesObservation). Skipping newer ones
  > 
  > # logical:
  > if ("GPKG" %in% st_drivers()$name) {
  + 	tst = read_sf(system.file("gpkg/nc.gpkg", package="sf"), quiet = TRUE) # default layer name
  + 	tst$bool = tst$NWBIR79 > 800 # logical
  + 	tst$bool[1:3] = NA
  + 	write_sf(tst, "tst__.gpkg")
  + 	tst2 = read_sf("tst__.gpkg")
  + 	stopifnot(identical(tst$bool, tst2$bool))
  + }
  Error in process_cpl_read_ogr(x, quiet, check_ring_dir = check_ring_dir,  : 
    package tibble not available: install first?
  Calls: read_sf ... st_read -> st_read.character -> process_cpl_read_ogr
  Execution halted
Running the tests in ‘tests/spatstat.R’ failed.
Complete output:
  > suppressPackageStartupMessages(library(sf))
  > if (require(spatstat.random, quietly = TRUE)) {
  + 
  + data(chicago)
  + st_as_sf(chicago)
  + # ppp:
  + g = gorillas
  + st_as_sf(g)
  + marks(g) = NULL
  + st_as_sf(g)
  + 
  + # multipolygon: https://github.com/r-spatial/sf/issues/1161
  + window = read_sf(system.file("shape/nc.shp", package = "sf")) %>%
  +   st_transform(32119)
  + 
  + win = spatstat.geom::as.owin(window)
  + 
  + set.seed(1331)
  + pp2a = runifpoint(n = 50, win = win)
  + print(st_as_sf(pp2a))
  + 
  + # st_sample going the spatstat way
  + x <- sf::st_sfc(sf::st_polygon(list(rbind(c(0, 0), c(10, 0), c(10, 10), c(0, 0)))))
  + try(pts <- st_sample(x, type = "thomas"))
  + try(pts <- st_sample(x, kappa = 1, mu = 10, type = "Thomas"))
  + # points expected
  + set.seed(1331)
  + pts <- st_sample(x, kappa = 1, mu = 10, scale = 0.1, type = "Thomas")
  + #plot(x)
  + #plot(pts, add = TRUE)
  + pts
  + 
  + # see https://github.com/r-spatial/sf/issues/1233
  + # png("/tmp/spa%03d.png")
  + 
  + p1 = st_point(0:1)
  + p2 = st_point(1:2)
  + p3 = st_point(c(-1,2))
  + p = st_sfc(p1, p2, p3)
  + as.ppp(p)
  + try(as.ppp(st_set_crs(p, 4326)))
  + 
  + sf = st_sf(geom = p)
  + try(as.ppp(sf))
  + sf = st_sf(a = 1:3, geom = p)
  + as.ppp(sf)
  + sf = st_sf(a = 1:3, b=3:1, geom = p)
  + as.ppp(sf) # warns
  + 
  + w = st_as_sfc(st_bbox(st_sfc(p1, p2)))
  + sf = st_sf(a = 1:3, geom = p)
  + (p0 = rbind(st_sf(a = 0, geom = w), sf))
  + suppressWarnings(try(as.ppp(p0))) # errors: one point outside window
  + 
  + w = st_as_sfc(st_bbox(p))
  + sf = st_sf(a = 1:3, geom = p)
  + (p0 = rbind(st_sf(a = 0, geom = w), sf))
  + as.ppp(p0)
  + 
  + # as.owin.sf, as.owin.sfc_*
  + nc = st_read(system.file("gpkg/nc.gpkg", package="sf"), check_ring_dir = TRUE, quiet = TRUE)
  + try(as.owin(nc)) # should be projected
  + nc = st_transform(nc, 32119)
  + plot(as.owin(nc), col = 'grey')
  + plot(as.owin(st_geometry(nc)), col = 'grey')
  + 
  + sq = rbind(c(-1,-1), c(1, -1), c(1,1), c(-1,1), c(-1,-1))
  + pol = st_polygon(list(0.5 * sq, sq[5:1,] * 0.45)) # w hole
  + plot(as.owin(pol), col = 'grey')
  + plot(as.owin(st_sfc(pol)), col = 'grey')
  + mpol = st_multipolygon(list(
  + 	list(sq, sq[5:1,] * 0.9),
  + 	list(sq * 2, sq[5:1,] * 1.8)))
  + plot(as.owin(mpol), col = 'grey')
  + plot(as.owin(st_sfc(mpol)), col = 'grey')
  + plot(as.owin(st_sfc(pol, mpol)), col = 'grey')
  + plot(as.owin(st_sf(a=1:2, st_sfc(pol, mpol))), col = 'grey')
  + (o = as.owin(st_sf(a=1:2, st_sfc(pol, mpol))))
  + st_as_sfc(o)
  + 
  + plot(st_as_sfc(o), col = 'blue', main = 'st_as_sfc(o)')
  + plot(st_as_sf(o), col = 'blue', main = 'st_as_sf(o)')
  + 
  + data(japanesepines)
  + st_as_sf(japanesepines) # warns about multiplier
  + jp = rescale(japanesepines)
  + st_as_sf(jp) # No warning
  + 
  + data(nztrees)
  + qNZ <- quadratcount(nztrees, nx=4, ny=3)
  + ts = as.tess(qNZ)
  + plot(st_as_sfc(ts))
  + 
  + ls = st_linestring(rbind(c(0,0), c(1,1), c(2,0)))
  + plot(as.psp(ls))
  + mls = st_multilinestring(list(rbind(c(0,0), c(1,1), c(2,0)), rbind(c(3,3), c(4,2))))
  + plot(as.psp(mls))
  + 
  + plot(as.psp(st_sfc(ls)))
  + plot(as.psp(st_sfc(mls)))
  + plot(as.psp(st_sfc(ls, mls)))
  + 
  + sf = st_sf(st_cast(st_sfc(ls, mls), "MULTILINESTRING"), marks = 1:2, foo = 2:1)
  + as.psp(sf) # picks marks itself
  + as.psp(sf, marks = 5:1)
  + 
  + (x = st_as_sf(as.psp(sf)))
  + (y = st_as_sfc(as.psp(sf)))
  + all.equal(st_geometry(x), y)
  + }
  spatstat.geom 3.2-9
  spatstat.random 3.2-3
  Error in process_cpl_read_ogr(x, quiet, check_ring_dir = check_ring_dir,  : 
    package tibble not available: install first?
  Calls: %>% ... st_read -> st_read.character -> process_cpl_read_ogr
  Execution halted