Skip to content

[PoC] Combine POINTs before st_as_grob() #2722

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions R/sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,22 @@ GeomSf <- ggproto("GeomSf", Geom,

# Need to refactor this to generate one grob per geometry type
coord <- coord$transform(data, panel_params)
grobs <- lapply(1:nrow(data), function(i) {
sf_grob(coord[i, , drop = FALSE])
})
if (inherits(data$geometry, "sfc_POINT")) {
coord <- utils::modifyList(default_aesthetics("point"), coord)
gp <- gpar(
col = alpha(coord$colour, coord$alpha),
fill = alpha(coord$fill, coord$alpha),
# Stroke is added around the outside of the point
fontsize = coord$size * .pt + coord$stroke * .stroke / 2,
lwd = coord$stroke * .stroke / 2
)
geometry <- sf::st_combine(coord$geometry)[[1]]
grobs <- list(sf::st_as_grob(geometry, gp = gp, pch = coord$shape))
} else {
grobs <- lapply(1:nrow(data), function(i) {
sf_grob(coord[i, , drop = FALSE])
})
}
do.call("gList", grobs)
},

Expand Down