Describe the bug
If the sf table includes x and y variables, they get selected by the predicate function instead of the geometry.
To Reproduce
library(dplyr)
library(sf)
a <- st_sfc(
st_point(c(1,1)),
st_point(c(2,2)),
st_point(c(3,3))
) |> st_sf(a = 1:3, geometry = _)
b <- st_sfc(
st_point(c(10,10)),
st_point(c(2,2)),
st_point(c(2,2)),
st_point(c(3,3))
) |> st_sf(a = 11:14, geom = _)
xy <- st_coordinates(a) |>
as_tibble() |>
rename_with(str_to_lower)
a <- bind_cols(a, xy)
st_filter(a |> select(-x, -y), b)
# Simple feature collection with 2 features and 1 field
# Geometry type: POINT
# Dimension: XY
# Bounding box: xmin: 2 ymin: 2 xmax: 3 ymax: 3
# CRS: NA
# a geometry
# 1 2 POINT (2 2)
# 2 3 POINT (3 3)
st_filter(a, b)
# Error in `stopifnot()`:
# ℹ In argument: `lengths(.predicate(x, y, ...)) > 0`.
# Caused by error in `UseMethod()`:
# ! no applicable method for 'st_intersects' applied to an object of class "c('double', 'numeric')"
# Run `rlang::last_trace()` to see where the error occurred.
If reporting a change from previous versions
NA
Additional context
From Edzer on Discord: "it seems like .predicate(!!x, !!y, ...) in st_filter.sf solves the issue"
Describe the bug If the sf table includes
x
andy
variables, they get selected by the predicate function instead of the geometry.To Reproduce
If reporting a change from previous versions NA
Additional context From Edzer on Discord: "it seems like .predicate(!!x, !!y, ...) in st_filter.sf solves the issue"