-
Notifications
You must be signed in to change notification settings - Fork 66
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
stplanr vulnerable to forthcoming changes in sp and rgdal #364
Comments
Thanks for the heads-up Roger, I'll brace myself and test things on the Docker container asap. |
Update on this: I get no errors when testing in @Nowosad's docker container that I started with:
Not tried on latest version of |
Just installed latest versions with:
|
Confirmed: I can reproduce the error. |
Heads-up @rsbivand, this is the offending PROJ string:
Reproducible example: library(stplanr)
data("routes_fast")
new_crs <- geo_select_aeq(routes_fast)
new_crs2 <- geo_select_aeq(routes_fast) # to be deprecated
identical(new_crs, new_crs2)
#> [1] TRUE
new_crs
#> CRS arguments:
#> +proj=aeqd +lat_0=53.81895189 +lon_0=-1.52748741 +x_0=0 +y_0=0
#> +datum=WGS84 +units=m +no_defs
plot(routes_fast) rf_projected <- sp::spTransform(routes_fast, new_crs)
#> Warning in spTransform(xSP, CRSobj, ...): NULL source CRS comment, falling
#> back to PROJ string
#> Error in .spTransform_Line(input[[i]], to_args = to_args, from_args = from_args, : source crs creation failed: Unknown error 1152454384 Created on 2019-11-16 by the reprex package (v0.3.0) |
Good, thanks for the updates. It is not impossible that the changes in
**sp** and **rgdal** should be wrapped up to moderate the collateral.
Roger
Roger Bivand
Falsensvei 32
5063 Bergen
lør. 16. nov. 2019, 23.51 skrev Robin <notifications@github.com>:
… Confirmed: I can reproduce the error.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#364?email_source=notifications&email_token=ACNZ3BBD3KQDZJMUB5YTBCDQUB2NNA5CNFSM4JOGOH6KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEH4KXI#issuecomment-554681693>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACNZ3BBB5PM45KVIJ5EVRMDQUB2NNANCNFSM4JOGOH6A>
.
|
No problem. More findings that may be of use/interest below: the function fails with library(stplanr)
buff_sp <- geo_buffer(routes_fast, width = 100)
#> Transforming to CRS +proj=aeqd +lat_0=53.81895189 +lon_0=-1.52748741 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs
#> Warning in spTransform(xSP, CRSobj, ...): NULL source CRS comment, falling
#> back to PROJ string
#> Error in .spTransform_Line(input[[i]], to_args = to_args, from_args = from_args, : source crs creation failed: invalid projection system error (-9999)
routes_fast_sf <- sf::st_as_sf(routes_fast)
#> Warning in CPL_crs_from_proj4string(x): GDAL Message 1: +init=epsg:XXXX
#> syntax is deprecated. It might return a CRS with a non-EPSG compliant axis
#> order.
buff_sf <- geo_buffer(routes_fast_sf, dist = 50)
plot(buff_sf$geometry, add = TRUE)
#> Error in polypath(p_bind(x[[i]]), border = border[i], lty = lty[i], lwd = lwd[i], : plot.new has not been called yet Created on 2019-11-16 by the reprex package (v0.3.0) |
FYI @rsbivand the functions generating those (now faulty?) PROJ strings are pasted below. I'm not sure what the next step is now we've roughly identified the culprit of the crashes, which is just the first step I guess. #' @export
geo_select_aeq <- function(shp) {
UseMethod("geo_select_aeq")
}
#' @export
geo_select_aeq.Spatial <- function(shp) {
cent <- rgeos::gCentroid(shp)
aeqd <- sprintf(
"+proj=aeqd +lat_0=%s +lon_0=%s +x_0=0 +y_0=0",
cent@coords[[2]], cent@coords[[1]]
)
sp::CRS(aeqd)
}
#' @export
geo_select_aeq.sf <- function(shp) {
cent <- sf::st_geometry(shp)
coords <- sf::st_coordinates(shp)
coords_mat <- matrix(coords[, 1:2], ncol = 2)
midpoint <- apply(coords_mat, 2, mean)
aeqd <- sprintf(
"+proj=aeqd +lat_0=%s +lon_0=%s +x_0=0 +y_0=0",
midpoint[2], midpoint[1]
)
sf::st_crs(aeqd)
} |
Problems still present with 0.5-0. Testing with sf 0.8-1, my sp 1.3-4 and rgdal 1.5-3:
|
That crashing code uses |
Update on this: I plan to make further changes, including updating the remain |
Closing for now, not because I think the issues are fixed but because I think deprecating the the failing |
Still an issue: Dear maintainer, Your package stplanr stores data objects using classes defined https://www.r-spatial.org/r/2020/03/17/wkt.html A section at the foot of describes possible steps for updating CRS objects; earlier sections cover http://spatial.nhh.no/R/rebuilt_sp_objects/ The functions used are from the development version of rgdal, 1.5-17, install.packages("rgdal", repos="http://R-Forge.R-project.org") and: remotes::install_github("rsbivand/sp") should you wish to make changes. Please check carefully that these objects |
New warning message from new CRSs with
Heads-up @rsbivand (many thanks for excellent guidance on updating stale CRSs). |
Good news, this seems to have fixed it: devtools::use_data(cents)
devtools::use_data(zones) Should be ready to merge the PR soon: #421 |
The pre-cooked |
@Robinlovelace I think, you can just use save(cents, file = "data/cents.rds", version = 2, compress = "bzip2") |
Thanks for the explanation, plan to set R >= 3.5.0 as a dependency. I think the warning happened on large (> 100 kB?) objects and am confident it would cause the CRAN checks to fail. Just saw Jakub's email. That would allow both compression and an older version. Given that sf depends on R > 3.3.0 will it make that much difference to users? If so I'll go with your solution, thanks for quickfire input Jakub! |
Just submitted spgwr with a 300K sp object - let's see ... |
Running revdep checks for current rgdal on R-Forge - see:
https://stat.ethz.ch/pipermail/r-sig-geo/2019-November/027801.html
shows the errors in the attached check log, related to use of PROJ&/GDAL3
and required changes to sp and rgdal. If useful find a regerence to a docker
image in this thread:
r-spatial/discuss#28
Changes will occur quite fast, and packages need to be prepared.
The text was updated successfully, but these errors were encountered: