1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> suppressPackageStartupMessages(library(sf))
> c(st_point(1:2), st_point(5:6))
MULTIPOINT ((1 2), (5 6))
> c(st_point(1:2), st_multipoint(matrix(5:8,2)))
MULTIPOINT ((1 2), (5 7), (6 8))
> c(st_multipoint(matrix(1:4,2)), st_multipoint(matrix(5:8,2)))
MULTIPOINT ((1 3), (2 4), (5 7), (6 8))
> c(st_linestring(matrix(1:6,3)), st_linestring(matrix(11:16,3)))
MULTILINESTRING ((1 4, 2 5, 3 6), (11 14, 12 15, 13 16))
> c(st_linestring(matrix(1:6,3)), st_multilinestring(list(matrix(11:16,3))))
MULTILINESTRING ((11 14, 12 15, 13 16), (1 4, 2 5, 3 6))
> c(st_multilinestring(list(matrix(1:6,3))), st_multilinestring(list(matrix(11:16,3))))
MULTILINESTRING ((1 4, 2 5, 3 6), (11 14, 12 15, 13 16))
> pl = list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)))
> c(st_polygon(pl), st_polygon(pl))
MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((0 0, 1 0, 1 1, 0 1, 0 0)))
> c(st_polygon(pl), st_multipolygon(list(pl)))
MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)), ((0 0, 1 0, 1 1, 0 1, 0 0)))
> c(st_linestring(matrix(1:6,3)), st_point(1:2))
GEOMETRYCOLLECTION (LINESTRING (1 4, 2 5, 3 6), POINT (1 2))
> c(st_geometrycollection(list(st_point(1:2), st_linestring(matrix(1:6,3)))),
+ st_geometrycollection(list(st_multilinestring(list(matrix(11:16,3))))))
GEOMETRYCOLLECTION (POINT (1 2), LINESTRING (1 4, 2 5, 3 6), MULTILINESTRING ((11 14, 12 15, 13 16)))
> c(st_geometrycollection(list(st_point(1:2), st_linestring(matrix(1:6,3)))),
+ st_multilinestring(list(matrix(11:16,3))), st_point(5:6),
+ st_geometrycollection(list(st_point(10:11))))
GEOMETRYCOLLECTION (MULTILINESTRING ((11 14, 12 15, 13 16)), POINT (5 6), POINT (1 2), LINESTRING (1 4, 2 5, 3 6), POINT (10 11))
> head(st_point(0:1), 2)
POINT (0 1)
>
> # Ops.sfg:
> ls = st_linestring(rbind(c(0,0),c(0,1)))
> pt = st_point(1:0)
> ls | pt
GEOMETRYCOLLECTION (LINESTRING (0 0, 0 1), POINT (1 0))
> ls / pt
LINESTRING (0 0, 0 1)
> ls & pt
GEOMETRYCOLLECTION EMPTY
> ls %/% pt
GEOMETRYCOLLECTION (LINESTRING (0 0, 0 1), POINT (1 0))
> # arith:
> ls + pt
LINESTRING (1 0, 1 1)
> ls - pt
LINESTRING (-1 0, -1 1)
> ls * pt
LINESTRING (0 0, 0 0)
> ls / pt
LINESTRING (0 0, 0 1)
> # unary:
> +pt
POINT (1 0)
> -pt
POINT (-1 0)
> try(!pt)
Error in Ops.sfg(pt) : unary ! not defined for "sfg" objects
>
> proc.time()
user system elapsed
0.331 0.016 0.340
|