Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return list of integers in matrix predicates #89

Open
kadyb opened this issue Jul 10, 2023 · 2 comments
Open

Return list of integers in matrix predicates #89

kadyb opened this issue Jul 10, 2023 · 2 comments

Comments

@kadyb
Copy link
Contributor

kadyb commented Jul 10, 2023

library("sf")
library("geos")

poly_sf = st_bbox(c(xmin = 0, xmax = 1, ymax = 0, ymin = 1), crs = st_crs(2180))
poly_sf = st_as_sfc(poly_sf)
pts_sf = st_sample(poly_sf, size = 10)
pts_geos = as_geos_geometry(pts_sf)
poly_geos = as_geos_geometry(poly_sf)

intersects_sf = sf::st_intersects(pts_sf, poly_sf)
typeof(intersects_sf[[1]])
#> [1] "integer"

intersects_geos = geos_intersects_matrix(pts_geos, poly_geos)
typeof(intersects_geos[[1]])
#> [1] "double"

Value
A list() of integer vectors containing the indices of tree for which the predicate would return TRUE.

The documentation says a list of integers will be returned, but it's actually double. The second issue, functions with the _any suffix return a logical vector.

@paleolimbot
Copy link
Owner

I should update the documentation...returning double allows support for vectors with more than 2 billion points (as rare as that is). Is the fact that it's not an integer causing a problem somewhere?

@kadyb
Copy link
Contributor Author

kadyb commented Jul 11, 2023

This is a good point. Integer has the advantage of taking up half the space than double. For example, {sf} just returns an integer, but like you said it won't work above 2 billion. The final decision is yours 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants