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

NAMESPACE re-working #99

Closed
dylanbeaudette opened this issue Mar 18, 2019 · 2 comments
Closed

NAMESPACE re-working #99

dylanbeaudette opened this issue Mar 18, 2019 · 2 comments
Assignees

Comments

@dylanbeaudette
Copy link
Member

dylanbeaudette commented Mar 18, 2019

Related to aqp/#85

This doesn't work, why?

library(soilDB)
data("loafercreek", package = 'soilDB')
slot(loafercreek, 'sp')
Error in e[1, 2] : subscript out of bounds

For now, R CMD build may fail while running examples. This has to do with method dispatch for plot.SoilprofileCollection.

@dylanbeaudette
Copy link
Member Author

@brownag
Copy link
Member

brownag commented Jan 16, 2021

Error in e[1, 2]: subscript out of bounds is what happens when you have an uninitialized SpatialPoints in the @sp slot of the SoilProfileCollection. It causes problems if you accidentally access it before setting up the Spatial slot with coordinates<-.

Was the loafercreek dataset historically serialized to file while promoted to Spatial-SPC? That could be the source of inconsistency here. Pretty sure I didn't do that the last several times I have built the object.

The SpatialPoints not having a viable EMPTY state is a major reason I favor lighter-weight option for the @sp slot -- a list/data.frame containing the coordinates, or just column names from @site (like other SPC slots: idname, hzdepthcols, hzidname) pointing at coordinates plus a place for the CRS. We could keep all the same S4 methods for setting things up -- just change to a simpler internal representation that we handle our own way, and provide conversion methods for if needed.

library(aqp, warn.conflicts = FALSE)
#> This is aqp 1.27
library(soilDB)

data("loafercreek", package = 'soilDB')
slot(loafercreek, 'sp')
#> class       : SpatialPoints 
#> features    : 1
#> Error in e[1, 2]: subscript out of bounds

loafersub <- subset(loafercreek, !is.na(x_std))
coordinates(loafersub) <- ~ x_std + y_std
slot(loafersub, 'sp')
#> class       : SpatialPoints 
#> features    : 106 
#> extent      : -121.4412, -120.2611, 37.68111, 39.51897  (xmin, xmax, ymin, ymax)
#> crs         : NA

@brownag brownag closed this as completed Jan 16, 2021
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