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
Deprecate sp / spatial tidiers? #392
Comments
Dave isn't sold, so we'll revisit this after the |
So it's worth noting perhaps that broom doesn't currently tidy any spatial objects beyond Example with library(sp)
# Build basic 2x2 polygon grid as SpatialPolygons
grd <- GridTopology(c(1,1), c(1,1), c(2,2))
polys <- as(grd, "SpatialPolygons")
class(polys)
#> [1] "SpatialPolygons"
#> attr(,"package")
#> [1] "sp"
pryr::otype(polys) # S4 not S3
#> [1] "S4"
broom::tidy(polys) # tidy
#> long lat order hole piece group id
#> 1 0.5 1.5 1 FALSE 1 g1.1 g1
#> 2 0.5 2.5 2 FALSE 1 g1.1 g1
#> 3 1.5 2.5 3 FALSE 1 g1.1 g1
#> 4 1.5 1.5 4 FALSE 1 g1.1 g1
#> 5 0.5 1.5 5 FALSE 1 g1.1 g1
#> 6 1.5 1.5 1 FALSE 1 g2.1 g2
#> 7 1.5 2.5 2 FALSE 1 g2.1 g2
#> 8 2.5 2.5 3 FALSE 1 g2.1 g2
#> 9 2.5 1.5 4 FALSE 1 g2.1 g2
#> 10 1.5 1.5 5 FALSE 1 g2.1 g2
#> 11 0.5 0.5 1 FALSE 1 g3.1 g3
#> 12 0.5 1.5 2 FALSE 1 g3.1 g3
#> 13 1.5 1.5 3 FALSE 1 g3.1 g3
#> 14 1.5 0.5 4 FALSE 1 g3.1 g3
#> 15 0.5 0.5 5 FALSE 1 g3.1 g3
#> 16 1.5 0.5 1 FALSE 1 g4.1 g4
#> 17 1.5 1.5 2 FALSE 1 g4.1 g4
#> 18 2.5 1.5 3 FALSE 1 g4.1 g4
#> 19 2.5 0.5 4 FALSE 1 g4.1 g4
#> 20 1.5 0.5 5 FALSE 1 g4.1 g4
sf::st_as_sf(polys) # sf conversion... tidy printing inherent
#> Simple feature collection with 4 features and 0 fields
#> geometry type: POLYGON
#> dimension: XY
#> bbox: xmin: 0.5 ymin: 0.5 xmax: 2.5 ymax: 2.5
#> epsg (SRID): NA
#> proj4string: NA
#> geometry
#> 1 POLYGON ((0.5 1.5, 0.5 2.5,...
#> 2 POLYGON ((1.5 1.5, 1.5 2.5,...
#> 3 POLYGON ((0.5 0.5, 0.5 1.5,...
#> 4 POLYGON ((1.5 0.5, 1.5 1.5,... Created on 2018-06-21 by the reprex package (v0.2.0). |
I use fortify the usual way, I don't think broom added anything except a well intended rationalization? When I care about speed or generality (ie sf as well) I use spbabel::sptable, but I'm probably alone in that sf::st_coordinates is the sf fortify, but returns a matrix and is named only by abstract 'level'. If you support sf with sf use that function, otherwise I'm happy to port a fortify/tidy.sf. Apologies for long winded comment! |
fwiw, where we are at for practicalities if anyone is wondering:
spbabel includes creating sp from a data frame, but if you can live with sf it's probably better to use sfheaders -> sf -> sp using sf's |
This issue has been automatically closed due to inactivity. |
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
We should probably just point people to
sf
and coercion methods there instead.The text was updated successfully, but these errors were encountered: