Lionel Hertzog shows off spatial capabilities in R:
All of these operations follow the same logic, st_operation(A, B) checks for each combinations of the geometries in A and B whether A operation B is true or false. For instance
st_within(A, B)
checks whether the geometries in A are within B, this is similar tost_contains(B, A)
, the difference between the two being the shape of the returned object. If A has n geometries and B has m,st_contains(B, A)
returns a list of length m where each elements contains the row IDs (numbers between 1 and n) of the geometries in A satisfying the operation. By usingsparse=FALSE
the functions returns matrices, likest_within(A, B, sparse=FALSE)
returns a n x m matrix,st_within(B, A, sparse=FALSE)
returns a m x n matrix. Note that running st_operation(A, A) checks the operation between all geometries of the object, so returning a n x n matrix.
Click through for part 1 of the series.