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

st_make_grid behaviour #1260

Closed
ericemc3 opened this issue Feb 9, 2020 · 3 comments
Closed

st_make_grid behaviour #1260

ericemc3 opened this issue Feb 9, 2020 · 3 comments

Comments

@ericemc3
Copy link

ericemc3 commented Feb 9, 2020

I am playing with the examples provided in https://www.rdocumentation.org/packages/sf/versions/0.8-0/topics/st_make_grid

Basically, we build a triangle and then compute a grid based on it.
First attempt with square=FALSE, it looks good with a hexagonal grid inside (or overlapping) the triangle:

sfc = st_sfc(st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,0)))))
plot(st_make_grid(sfc, cellsize = .1, square = FALSE))
plot(sfc, add = TRUE)

Second attempt with square=TRUE, I'm surprised to get a grid that expands over the whole box bounding the triangle:

sfc = st_sfc(st_polygon(list(rbind(c(0,0), c(1,0), c(1,1), c(0,0)))))
plot(st_make_grid(sfc, cellsize = .1, square = TRUE))
plot(sfc, add = TRUE)

Actually, the doc says:
Create a square or hexagonal grid over the bounding box of an sf or sfc object,

so the second attempt looks consistent with the doc, but not the first one, although i'd prefer the first behaviour for more generic purposes (build a grid inside any polygon). Am i missing something here?

grid1

grid2

edzer added a commit that referenced this issue Feb 9, 2020
@edzer
Copy link
Member

edzer commented Feb 9, 2020

Thanks; I also like it better if the grid covers the geometries rather than their bounding box; let's see whether this triggers protest.

@ericemc3
Copy link
Author

Thanks a lot

edzer added a commit that referenced this issue Feb 10, 2020
@edzer edzer closed this as completed Feb 10, 2020
@ericemc3
Copy link
Author

Thanks for the quick fix

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