-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
crs structure is going to change #49
Comments
Thanks @edzer - I'll make the changes ready for the next release. |
From r-spatial/sf#1225
I have changed the crs object to be two Rcpp::String crs_input,
Rcpp::String crs_wkt,
// attribute::crs
Rcpp::List crs = Rcpp::List::create(
Rcpp::Named("input") = crs_input,
Rcpp::Named("wkt") = crs_wkt
); df <- data.frame(x = 1, y = 2)
sf <- sfheaders::sf_point(df)
a <- attributes( sf$geometry )
expect_true( is.character( a$crs$input ) )
expect_true( is.character( a$crs$wkt ) ) Will test when new |
Since this package does not depend in any way on |
The tests should handle this ideally, I would imagine. FYI I have a minimal reprex that shows how the current version of library(sfheaders)
x <- matrix( c(1:4), ncol = 2 )
xsfc <- sfc_linestring( x )
sf::st_crs(xsfc)
#> Coordinate Reference System: NA
xsfc <- sfc_linestring( x , crs = 4326)
#> Error in sfc_linestring(x, crs = 4326): unused argument (crs = 4326)
# with sf
xsfc2 <- sf::st_sfc(sf::st_linestring(x))
identical(xsfc, xsfc2)
#> [1] FALSE
# crss
attributes(xsfc)
#> $n_empty
#> [1] 0
#>
#> $crs
#> Coordinate Reference System: NA
#>
#> $class
#> [1] "sfc_LINESTRING" "sfc"
#>
#> $precision
#> [1] 0
#>
#> $bbox
#> xmin ymin xmax ymax
#> 1 3 2 4
#>
#> $z_range
#> zmin zmax
#> NA NA
#>
#> $m_range
#> mmin mmax
#> NA NA
attr(xsfc, which = "crs") = 4326
sf::st_crs(xsfc)
#> [1] 4326
xsfc2 <- sf::st_sfc(sf::st_linestring(x), crs = 4326)
sf::st_crs(xsfc2)
#> Coordinate Reference System:
#> EPSG: 4326
#> proj4string: "+proj=longlat +datum=WGS84 +no_defs"
identical(xsfc, xsfc2)
#> [1] FALSE Created on 2020-02-08 by the reprex package (v0.3.0) Great to see efforts to align |
This aligning could happen but has to happened here. Currently, AFAICT, the goal of |
May be 'none of my business' but, having just read the comment above, I'd advocate adding |
@edzer I don't have any specific mechanisms in place other than following your output and keeping on top of it.
yes exactly right. Perhaps the solution is to 'suggest' |
These structures should stay as they were. Just add slots, that's how you maintain compatibility, and friends. sp built enormous good will, despite limitations |
In response to @edzer's comments
and
Open source communities fragment, diverge, and function best in the absence of attempts to enforce centralised control. The ap <- available.packages ()
ap <- ap [grep ("^gg", ap [, 1]), ]
dep <- ap [, grep ("Depends", colnames (ap))]
sug <- ap [, grep ("Suggests", colnames (ap))]
ggdep <- grepl ("ggplot", dep)
ggsug <- grepl ("ggplot", sug)
message ("Depends: ", length (which (ggdep)), " packages, or ",
signif (100 * length (which (ggdep)) / nrow (ap), 3), "%")
#> Depends: 46 packages, or 38.7%
message ("Suggests: ", length (which (ggsug)), " packages, or ",
signif (100 * length (which (ggsug)) / nrow (ap), 3), "%")
#> Suggests: 5 packages, or 4.2%
n_neither <- nrow (ap) - length (which (ggdep)) - length (which (ggsug))
message ("Neither Depends nor Suggests = ",
n_neither, ", or ", signif (100 * n_neither / nrow (ap), 3), "%")
#> Neither Depends nor Suggests = 68, or 57.1% Created on 2020-04-12 by the reprex package (v0.3.0) The majority of Edit: I forgot Imports there, which is 62 of those final 68%, but that still leaves > 5% neither Depending, Importing, or Suggesting. |
Mark, fair enough, but this is not about gate keeping representations, this is about user expectations. I'm entirely OK if any package goes its own way representing simple features (or whatever spatial data structures) the way they want, it is just that if users want to plot stuff with Think of it like this: suppose your package creates its own grouped tibbles and give them class Now you and @mdsumner seem to have strong opinions about this that apparently differ from mine, but I would be interested to hear what @dcooley thinks about what users of |
An example of a diverging simple feature implementation done non-disruptively by the great @paleolimbot : https://twitter.com/paleolimbot/status/1249142366776315904 |
Thanks for the input everyone. I think for the R side of Going further, 90% of the code in this Then anyone can use this general reshaping code, put their own R-class on top of it and use it in their own library / structures. If @mdsumner @edzer @Robinlovelace @paleolimbot @mpadge (or other interested party reading this thread) have any thoughts on this I'd bee keen to hear it.
@paleolimbot - do you know how to set this up? |
I think you can stick
Before or after this (I forget which is more likely to work): https://github.com/dcooley/sfheaders/blob/master/.github/workflows/R-CMD-check.yaml#L68 ...in a copy of your R-CMD-check.yaml file. If you're going return an object of class If there is an in-memory structure that's faster to create (from a data frame or otherwise), you could give it another class ("sfheaders"?) and implement |
This as a general tool used by narrower scope packages is exactly how things should work in my opinion. This is a core piece that sf should import ... It's redundant and insulting to need to say so, and no one should feel that pressure. Abstraction from format is an obvious requirement. Not everything is a simple feature and those are only sometimes useful, especially when only one mode is available. What else is there to say ... Thanks @dcooley amazing bit of kit! The wkt thing is a problem, no one is ignoring it but this is software we can have flexibility not just one size fits all if we want to. Diverse approaches that want to generate a commonly used format at lightning speed from a wide range of inputs is a massive win win for everyone in my view. It's incredible to me to enforce a cm precision crs string at all times, with the transformation library always present - but then not use them for map plotting and binary ops, but I'm happy for diverse approaches as long as they don't limit what others can do. (Sorry, totally redundant and obvious again ...) |
Closing this issue because I've made the changes, and need to get a patch on CRAN for a bug I found. But have moved the "test against sf objects" to a new issue because it's still worthwhile, but I don't have the time to do it before release. |
This is just a heads up: since sfheaders does not depend on sf, it is not checked in my rev dep checks. Following drastic PROJ and GDAL changes, upcoming sf (branch SetFromUserInput in github) will have a different structure for crs objects; see r-spatial/sf#1244 and r-spatial/sf#1225 . It looks like sfheaders hard-codes them to be as they used to be.
The text was updated successfully, but these errors were encountered: