Learn R Programming

sf (version 0.4-3)

st_join: spatial left or inner join

Description

spatial left or inner join

Usage

st_join(x, y, join = st_intersects, FUN, suffix = c(".x", ".y"),
  prepared = TRUE, left = TRUE)

Arguments

x

object of class sf

y

object of class sf

join

geometry predicate function with the same profile as st_intersects; see details

FUN

aggregation function, see aggregate; in case of multiple matches, if FUN is defined, attributes of y will be aggregated using FUN; else, all combinations of x and y are returned.

suffix

length 2 character vector; see merge

prepared

logical; see st_intersects

left

logical; if TRUE carry out left join, else inner join; see also left_join

Value

an object of class sf, joined based on geometry

Details

alternative values for argument join are: st_disjoint st_touches st_crosses st_within st_contains st_overlaps st_covers st_covered_by st_equals or st_equals_exact, or user-defined functions of the same profile

Examples

Run this code
a = st_sf(a = 1:3,
 geom = st_sfc(st_point(c(1,1)), st_point(c(2,2)), st_point(c(3,3))))
b = st_sf(a = 11:14,
 geom = st_sfc(st_point(c(10,10)), st_point(c(2,2)), st_point(c(2,2)), st_point(c(3,3))))
st_join(a, b)
st_join(a, b, left = FALSE)
st_join(a, b, FUN = mean)
st_join(a, b, FUN = mean, left = FALSE)

Run the code above in your browser using DataLab