You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating sf library from version sf_1.0-9 to latest (sf_1.0-12) I realize sf::st_sample() is not working for longlat coordinates objects as expected (WGS84 in my case).
I noticed that there have been changes in the source code of the function but I was not able to fix it. The code seems to go into an endless loop.
For a reproducible example, consider this code snippet, which should run with version 1.0-9 (where it works) and the latest 1.0-12 (where it doesn't).
library(sf)
x = st_sfc(st_polygon(list(rbind(c(0,0),c(45.1,0),c(45.1,45.2),c(0,45.2),c(0,0)))), crs = st_crs(4326))
st_sample(x, size = c(2,2), type = "random")
While the same code works fine in both version when crs is set to UTM coordinates (crs=32721):
library(sf)
x = st_sfc(st_polygon(list(rbind(c(0,0),c(45.1,0),c(45.1,45.2),c(0,45.2),c(0,0)))), crs = st_crs(32721))
st_sample(x, size = c(2,2), type = "random")
Thanks
The text was updated successfully, but these errors were encountered:
Right, with exact = FALSE it returns, but TRUE (default) it doesn't.
edzer
changed the title
st_sample() get frezze when objects has longlat projection (like crs=4326)
st_sample() does not finish when objects has longlat projection (like crs=4326)
Mar 26, 2023
When updating sf library from version sf_1.0-9 to latest (sf_1.0-12) I realize
sf::st_sample()
is not working for longlat coordinates objects as expected (WGS84 in my case).I noticed that there have been changes in the source code of the function but I was not able to fix it. The code seems to go into an endless loop.
For a reproducible example, consider this code snippet, which should run with version 1.0-9 (where it works) and the latest 1.0-12 (where it doesn't).
While the same code works fine in both version when crs is set to UTM coordinates (crs=32721):
Thanks
The text was updated successfully, but these errors were encountered: