-
Notifications
You must be signed in to change notification settings - Fork 303
/
Copy pathsfg.R
34 lines (33 loc) · 1.1 KB
/
sfg.R
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
suppressPackageStartupMessages(library(sf))
c(st_point(1:2), st_point(5:6))
c(st_point(1:2), st_multipoint(matrix(5:8,2)))
c(st_multipoint(matrix(1:4,2)), st_multipoint(matrix(5:8,2)))
c(st_linestring(matrix(1:6,3)), st_linestring(matrix(11:16,3)))
c(st_linestring(matrix(1:6,3)), st_multilinestring(list(matrix(11:16,3))))
c(st_multilinestring(list(matrix(1:6,3))), st_multilinestring(list(matrix(11:16,3))))
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))
c(st_polygon(pl), st_multipolygon(list(pl)))
c(st_linestring(matrix(1:6,3)), st_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))))))
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))))
head(st_point(0:1), 2)
# Ops.sfg:
ls = st_linestring(rbind(c(0,0),c(0,1)))
pt = st_point(1:0)
ls | pt
ls / pt
ls & pt
ls %/% pt
# arith:
ls + pt
ls - pt
ls * pt
ls / pt
# unary:
+pt
-pt
try(!pt)