Skip to content

Commit 4db5122

Browse files
yutannihilationhadley
authored andcommitted
add fortify() method for sfc and sfg (#2685)
1 parent cc48035 commit 4db5122

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ S3method(fortify,glht)
3838
S3method(fortify,grouped_df)
3939
S3method(fortify,lm)
4040
S3method(fortify,map)
41+
S3method(fortify,sfc)
42+
S3method(fortify,sfg)
4143
S3method(fortify,summary.glht)
4244
S3method(fortify,tbl)
4345
S3method(ggplot,"function")

R/fortify-spatial.r

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,16 @@ fortify.Line <- function(model, data, ...) {
108108
df$order <- 1:nrow(df)
109109
df
110110
}
111+
112+
113+
#' @export
114+
#' @method fortify sfc
115+
fortify.sfc <- function(model, data, ...) {
116+
sf::st_sf(geometry = model)
117+
}
118+
119+
#' @export
120+
#' @method fortify sfg
121+
fortify.sfg <- function(model, data, ...) {
122+
sf::st_sf(geometry = sf::st_sfc(model))
123+
}

0 commit comments

Comments
 (0)