-
Notifications
You must be signed in to change notification settings - Fork 300
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_crop does not work correctly with bounding box with geographic coordinates. #2443
Comments
Please provide a reproducible example, and note that bounding boxes are not rectangular in geographical coordinates. |
Here is a working example:
I would expect the result I get with |
Why use
|
My original code is much more extensive. It uses a lot of Note: I do plan to switch my project from |
Well, if your workflow depended on pre- |
I'm also using |
Using planar computation on spherical geometries is always "wrong", but has been accepted as computing on the sphere was seen as too difficult (see the quote we used as the motto in our chapter). The differences stem from treating lines between two points on the surface of a sphere as "straight" when they most often are curves, hence S2 which is bounded and wraps around, as contrasted with R2, where the coordinates are on two real dimensions from -Inf to +Inf. |
Thank you. So my take-away is that the behaviour of |
Yes, especially for workflows involving vector geometries. Rasters are not so obvious, because planar rasters have equal area cells across the whole study area, which is not the case on the sphere in general. So some analysts may prefer approaches through for example |
@sostberg I think that reading https://r-spatial.org/book/04-Spherical.html may help you to grasp the general idea |
Switching |
Describe the bug
I'm trying to cut out a subset of features from a simple feature collection using a bounding box. The simple feature collection uses geographic lon/lat coordinates.
The resulting simple feature collection does have a larger bounding box than would I supplied to
st_crop
. More importantly, it does not contain all the features from the original sf object that fall within the bounding box.st_crop
seems to work correctly if I switch off s2 functionality (sf_use_s2(FALSE)
). Is this the only possible fix? Should s2 functionality be switched off in general if working with lon/lat data?The text was updated successfully, but these errors were encountered: