knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
In sp_df
we can store the Spatial*
(without the DataFrame) geometry in a special column.
geocol <- sp_df(wrld_simpl) geocol %>% dplyr::select(NAME, Spatial_)
Note that this approach can be easily applied with WKT or WKB, it's just a fair bit of extra work to do the type conversion when needed. Note that, R has a raw
type that seamlessly handles WKB from many DBs, and the wkb
package can read it, likewise with rgeos::readWKT
and rgeos::writeWKT
. (See this in action in manifoldr.)
Can we use mutate with the as coercion?
spdf <- sp_df(wrld_simpl) ## this doesn't work #spdf %>% mutate(Spatial_ = as(Spatial_, "SpatialLines")) spdf$Spatial_ <- as(spdf$Spatial_, "SpatialLines")
How to apply this, as an extra class? Note that geom_polygon in gggeom does not survive filter since the class attribute is lost.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.