Running ‘aggregate.R’
  Comparing ‘aggregate.Rout’ to ‘aggregate.Rout.save’ ...4c4
< Linking to GEOS 3.6.1, GDAL 2.2.4, PROJ 4.9.3
---
> Linking to GEOS 3.6.2, GDAL 2.2.3, PROJ 4.9.3
  Running ‘cast.R’
  Comparing ‘cast.Rout’ to ‘cast.Rout.save’ ... OK
  Running ‘crs.R’
  Comparing ‘crs.Rout’ to ‘crs.Rout.save’ ... OK
  Running ‘dist.R’
  Comparing ‘dist.Rout’ to ‘dist.Rout.save’ ... OK
  Running ‘dplyr.R’
  Comparing ‘dplyr.Rout’ to ‘dplyr.Rout.save’ ... OK
  Running ‘empty.R’
  Comparing ‘empty.Rout’ to ‘empty.Rout.save’ ... OK
  Running ‘gdal_geom.R’
  Comparing ‘gdal_geom.Rout’ to ‘gdal_geom.Rout.save’ ... OK
  Running ‘geos.R’
  Running ‘graticule.R’
  Comparing ‘graticule.Rout’ to ‘graticule.Rout.save’ ... OK
  Running ‘grid.R’
  Comparing ‘grid.Rout’ to ‘grid.Rout.save’ ... OK
  Running ‘plot.R’
  Comparing ‘plot.Rout’ to ‘plot.Rout.save’ ... OK
  Running ‘read.R’
  Comparing ‘read.Rout’ to ‘read.Rout.save’ ...336c336
< Reading layer `Parcely' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/sf/gml/20170930_OB_530964_UKSH.xml.gz' using driver `GML'
---
> Reading layer `Parcely' from data source `/home/edzer/git/sf.Rcheck/sf/gml/20170930_OB_530964_UKSH.xml.gz' using driver `GML'
354c354
< Reading layer `Parcely' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/sf/gml/20170930_OB_530964_UKSH.xml.gz' using driver `GML'
---
> Reading layer `Parcely' from data source `/home/edzer/git/sf.Rcheck/sf/gml/20170930_OB_530964_UKSH.xml.gz' using driver `GML'
386c386
< Reading layer `tst__' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/tests/tst__.gpkg' using driver `GPKG'
---
> Reading layer `tst__' from data source `/home/edzer/git/sf.Rcheck/tests/tst__.gpkg' using driver `GPKG'
  Running ‘roundtrip.R’
  Comparing ‘roundtrip.Rout’ to ‘roundtrip.Rout.save’ ... OK
  Running ‘sfc.R’
  Comparing ‘sfc.Rout’ to ‘sfc.Rout.save’ ...388c388
< "3.6.1" "2.2.4" "4.9.3" 
---
> "3.6.2" "2.2.3" "4.9.3" 
702c702
< Reading layer `nc' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/sf/shape/nc.shp' using driver `ESRI Shapefile'
---
> Reading layer `nc' from data source `/home/edzer/git/sf.Rcheck/sf/shape/nc.shp' using driver `ESRI Shapefile'
  Running ‘sfg.R’
  Comparing ‘sfg.Rout’ to ‘sfg.Rout.save’ ... OK
  Running ‘stars.R’
  Comparing ‘stars.Rout’ to ‘stars.Rout.save’ ...56a57,171
> [1] TRUE
> [1] TRUE
> Geometry set for 30 features 
> geometry type:  POINT
> dimension:      XY
> bbox:           xmin: 0 ymin: 0.3 xmax: 5 ymax: 2.2
> epsg (SRID):    NA
> proj4string:    NA
> First 5 geometries:
> POINT (0 0.3)
> POINT (0.5 0.3)
> POINT (1 0.3)
> POINT (2 0.3)
> POINT (4 0.3)
> Geometry set for 30 features 
> geometry type:  POLYGON
> dimension:      XY
> bbox:           xmin: -0.25 ymin: 0.2 xmax: 5.5 ymax: 2.3
> epsg (SRID):    NA
> proj4string:    NA
> First 5 geometries:
> POLYGON ((-0.25 0.2, 0.25 0.2, 0.25 0.4, -0.25 ...
> POLYGON ((0.25 0.2, 0.75 0.2, 0.75 0.4, 0.25 0....
> POLYGON ((0.75 0.2, 1.5 0.2, 1.5 0.4, 0.75 0.4,...
> POLYGON ((1.5 0.2, 3 0.2, 3 0.4, 1.5 0.4, 1.5 0...
> POLYGON ((3 0.2, 4.5 0.2, 4.5 0.4, 3 0.4, 3 0.2))
> Geometry set for 20 features 
> geometry type:  POINT
> dimension:      XY
> bbox:           xmin: 1 ymin: 1 xmax: 5 ymax: 4
> epsg (SRID):    4326
> proj4string:    +proj=longlat +datum=WGS84 +no_defs
> First 5 geometries:
> POINT (1 1)
> POINT (1 2)
> POINT (1 3)
> POINT (1 4)
> POINT (2 1)
> Geometry set for 20 features 
> geometry type:  POLYGON
> dimension:      XY
> bbox:           xmin: 0.5 ymin: 0.5 xmax: 5.5 ymax: 4.5
> epsg (SRID):    4326
> proj4string:    +proj=longlat +datum=WGS84 +no_defs
> First 5 geometries:
> POLYGON ((0.5 0.5, 0.5 1.5, 1.5 1.5, 1.5 0.5, 0...
> POLYGON ((0.5 1.5, 0.5 2.5, 1.5 2.5, 1.5 1.5, 0...
> POLYGON ((0.5 2.5, 0.5 3.5, 1.5 3.5, 1.5 2.5, 0...
> POLYGON ((0.5 3.5, 0.5 4.5, 1.5 4.5, 1.5 3.5, 0...
> POLYGON ((1.5 0.5, 1.5 1.5, 2.5 1.5, 2.5 0.5, 1...
> Reading layer `nc.gpkg' from data source `/home/edzer/git/sf.Rcheck/sf/gpkg/nc.gpkg' using driver `GPKG'
> Simple feature collection with 100 features and 14 fields
> Attribute-geometry relationship: 0 constant, 8 aggregate, 6 identity
> geometry type:  MULTIPOLYGON
> dimension:      XY
> bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
> epsg (SRID):    4267
> proj4string:    +proj=longlat +datum=NAD27 +no_defs
> stars object with 2 dimensions and 1 attribute
> attribute(s):
>      AREA       
>  Min.   :0.042  
>  1st Qu.:0.108  
>  Median :0.142  
>  Mean   :0.145  
>  3rd Qu.:0.181  
>  Max.   :0.241  
>  NA's   :30726  
> dimension(s):
>   from  to   offset      delta                       refsys point values    
> x    1 360 -84.3239  0.0246302 +proj=longlat +datum=NAD2... FALSE   NULL [x]
> y    1 180  36.5896 -0.0150425 +proj=longlat +datum=NAD2... FALSE   NULL [y]
> Simple feature collection with 135 features and 1 field
> geometry type:  POLYGON
> dimension:      XY
> bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
> epsg (SRID):    NA
> proj4string:    +proj=longlat +ellps=clrk66 +no_defs
> First 10 features:
>     AREA                       geometry
> 1  0.070 POLYGON ((-75.90032 36.5595...
> 2  0.070 POLYGON ((-76.02347 36.5595...
> 3  0.070 POLYGON ((-75.87569 36.5144...
> 4  0.061 POLYGON ((-81.3436 36.57461...
> 5  0.091 POLYGON ((-76.93479 36.5595...
> 6  0.070 POLYGON ((-75.85106 36.4392...
> 7  0.070 POLYGON ((-75.82643 36.3640...
> 8  0.062 POLYGON ((-76.56534 36.5595...
> 9  0.153 POLYGON ((-80.01357 36.5445...
> 10 0.114 POLYGON ((-79.52096 36.5445...
> Simple feature collection with 32 features and 1 field
> geometry type:  POLYGON
> dimension:      XY
> bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
> epsg (SRID):    NA
> proj4string:    +proj=longlat +ellps=clrk66 +no_defs
> First 10 features:
>    AREA                       geometry
> 1     0 POLYGON ((-75.90032 36.5595...
> 2     0 POLYGON ((-76.02347 36.5595...
> 3     0 POLYGON ((-75.87569 36.5144...
> 4     0 POLYGON ((-75.85106 36.4392...
> 5     0 POLYGON ((-75.82643 36.3640...
> 6     0 POLYGON ((-75.8018 36.27376...
> 7     0 POLYGON ((-75.77717 36.2135...
> 8     0 POLYGON ((-75.67865 36.0180...
> 9     0 POLYGON ((-75.65402 35.9729...
> 10    0 POLYGON ((-75.62939 35.9277...
> Error in CPL_polygonize(file, mask_name, "GTiff", "Memory", "foo", character(0),  : 
>   contour only available in GDAL >= 2.4.0
> [1] "Error in CPL_polygonize(file, mask_name, \"GTiff\", \"Memory\", \"foo\", character(0),  : \n  contour only available in GDAL >= 2.4.0\n"
> attr(,"class")
> [1] "try-error"
> attr(,"condition")
> <Rcpp::exception in CPL_polygonize(file, mask_name, "GTiff", "Memory", "foo", character(0),     0, contour_options, use_contours, use_integer): contour only available in GDAL >= 2.4.0>
  Running ‘testthat.R’
  Comparing ‘testthat.Rout’ to ‘testthat.Rout.save’ ...8,9c8,9
< Reading layer `nospatial' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/sf/gpkg/nospatial.gpkg' using driver `GPKG'
< Reading layer `nospatial' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/sf/gpkg/nospatial.gpkg' using driver `GPKG'
---
> Reading layer `nospatial' from data source `/home/edzer/git/sf.Rcheck/sf/gpkg/nospatial.gpkg' using driver `GPKG'
> Reading layer `nospatial' from data source `/home/edzer/git/sf.Rcheck/sf/gpkg/nospatial.gpkg' using driver `GPKG'
11c11
< Reading layer `nc' from data source `/data/gannet/ripley/R/packages/tests-clang/sf.Rcheck/sf/shape/nc.shp' using driver `ESRI Shapefile'
---
> Reading layer `nc' from data source `/home/edzer/git/sf.Rcheck/sf/shape/nc.shp' using driver `ESRI Shapefile'
19c19
< Dataset /tmp/RtmpHXS8TV/file984e314f9d1b.gpkg already exists: remove first, use update=TRUE to append,
---
> Dataset /tmp/RtmpQlN0Qx/file3032144b20ef.gpkg already exists: remove first, use update=TRUE to append,
  Running ‘units.R’
  Comparing ‘units.Rout’ to ‘units.Rout.save’ ... OK
  Running ‘wkb.R’
  Comparing ‘wkb.Rout’ to ‘wkb.Rout.save’ ... OK
  Running ‘zzz.R’
  Comparing ‘zzz.Rout’ to ‘zzz.Rout.save’ ... OK
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  25652.53 440561.15 299772.18 361529.53 419671.2
   [2,]      0.00      0.00      0.00 409428.54 268944.31 332589.77 388544.5
   [3,]  25652.53      0.00      0.00 367555.48 227017.51 290297.10 346667.9
   [4,] 440561.15 409428.54 367555.48      0.00  67226.86  45537.55      0.0
   [5,] 299772.18 268944.31 227017.51  67226.86      0.00      0.00  46527.4
   [6,] 361529.53 332589.77 290297.10  45537.55      0.00      0.00  30213.0
   [7,] 419671.16 388544.52 346667.93      0.00  46527.40  30213.00      0.0
   [8,] 384592.90 354294.11 312350.68  16130.34  11926.81      0.00      0.0
   [9,] 262354.29 231217.49 189310.35 140455.87      0.00  64606.24 119563.7
  [10,]  71139.29  41943.83      0.00 330751.39 190182.39 252372.06 309862.0
             [,8]      [,9]     [,10]
   [1,] 384592.90 262354.29  71139.29
   [2,] 354294.11 231217.49  41943.83
   [3,] 312350.68 189310.35      0.00
   [4,]  16130.34 140455.87 330751.39
   [5,]  11926.81      0.00 190182.39
   [6,]      0.00  64606.24 252372.06
   [7,]      0.00 119563.73 309861.97
   [8,]      0.00  85533.12 275389.78
   [9,]  85533.12      0.00 152488.92
  [10,] 275389.78 152488.92      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
  bbox:           xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
  epsg (SRID):    4267
  proj4string:    +proj=longlat +datum=NAD27 +no_defs
  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
  > 
  > g = st_make_grid(nc)
  > x = st_intersection(nc, g)
  although coordinates are longitude/latitude, st_intersection assumes that they are planar
  Warning message:
  attribute variables are assumed to be spatially constant throughout all geometries 
  > x = st_intersection(g, nc)
  although coordinates are longitude/latitude, st_intersection assumes that they are planar
  > 
  > ls = st_sfc(st_linestring(rbind(c(0,0),c(0,1))),
  + st_linestring(rbind(c(0,0),c(10,0))))
  > 
  > set.seed(13531) # make reproducible
  > 
  > st_line_sample(ls, density = 1, type = "random")
  Geometry set for 2 features 
  geometry type:  MULTIPOINT
  dimension:      XY
  bbox:           xmin: 0 ymin: 0 xmax: 6.880179 ymax: 0.8878369
  epsg (SRID):    NA
  proj4string:    NA
  MULTIPOINT (0 0.8878369)
  MULTIPOINT (0.2986488 0, 2.48417 0, 2.567813 0,...
  > 
  > g = st_make_grid(nc, n = c(20,10))
  > 
  > a1 = st_interpolate_aw(nc["BIR74"], g, FALSE)
  although coordinates are longitude/latitude, st_intersection assumes that they are planar
  Warning message:
  In st_interpolate_aw(nc["BIR74"], g, FALSE) :
    st_interpolate_aw assumes attributes are constant over areas of x
  > sum(a1$BIR74) / sum(nc$BIR74) # not close to one: property is assumed spatially intensive
  [1] 1.436169
  > a2 = st_interpolate_aw(nc["BIR74"], g, extensive = TRUE)
  although coordinates are longitude/latitude, st_intersection assumes that they are planar
  Warning message:
  In st_interpolate_aw(nc["BIR74"], g, extensive = TRUE) :
    st_interpolate_aw assumes attributes are constant over areas of x
  > sum(a2$BIR74) / sum(nc$BIR74)
  [1] 1.000013
  > 
  > # 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(nc, 0.1, what = "polygons", square = FALSE)
  although coordinates are longitude/latitude, st_relate_pattern assumes that they are planar
  > g2 = st_make_grid(nc, 0.1, what = "points", square = FALSE)
  although coordinates are longitude/latitude, st_intersects assumes that they are planar
  > 
  > # 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 (sf_extSoftVersion()["GEOS"] >= "3.5.0") {
  +  # 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_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 in CPL_geos_binop(st_geometry(x), st_geometry(y), op, par, pattern,  : 
    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
  > 
  > 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, 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] 110574.4 110575.1 221149.5
  > 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
  bbox:           xmin: 0 ymin: 0 xmax: 1 ymax: 1
  epsg (SRID):    NA
  proj4string:    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
  bbox:           xmin: 0 ymin: 0 xmax: 1 ymax: 1
  epsg (SRID):    NA
  proj4string:    NA
    a                      st_sfc.l.
  1 1 MULTILINESTRING ((0 0, 0.5 ...
  > 
  > # print.sgbp:
  > (lst = st_disjoint(nc, nc))
  although coordinates are longitude/latitude, st_intersects assumes that they are planar
  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
  > 
  > 
  > # 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
  terminate called after throwing an instance of 'std::__1::bad_function_call'
    what():  std::exception