Skip to content

Better sf support - #3164

Merged
thomasp85 merged 3 commits into
tidyverse:masterfrom
thomasp85:better-sf
Mar 5, 2019
Merged

thomasp85 merged 3 commits into
tidyverse:masterfrom
thomasp85:better-sf

Conversation

@thomasp85

Copy link
Copy Markdown
Member

This PR adapts geom_sf and coord_sf to make use of the improvements in performance introduced in sf v0.7-3. The changes are as follows:

  • Use st_normalize during rescaling to greatly speed up `coord_sf
  • Construct a single grob from the geometry and let sf decide on how/if to split it up to multiple grobs

This PR introduces a new version dependency on sf as it does not make much sense to support both implementations simultaneously

@yutannihilation

Copy link
Copy Markdown
Member

This fixes #2718 at last. Thanks Thomas!

@clauswilke

Copy link
Copy Markdown
Member

This looks good to me in principle, but I don't have time this week to go over it in detail (proofing my book this week, and likely reformatting many of the figures).

I think increasing the required sf version is good anyways, because otherwise axis ticks may be placed in the wrong location due to a pernicious bug that was only recently fixed.

@yutannihilation yutannihilation left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments.

By the way, it's not necessarily included in this PR, but can we add some simple tests about the gpar() is built as intended?

Comment thread R/geom-sf.R Outdated
}
geometry <- x$geometry
type <- sf_types[sf::st_geometry_type(geometry)]
is_point <- type %in% 'point'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops - nice catch. My life is a constant struggle between my own preference and Hadleys ;-)

Comment thread R/geom-sf.R Resolved

@hadley hadley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me.

Comment thread R/geom-sf.R
type <- sf_types[sf::st_geometry_type(geometry)]
is_point <- type %in% 'point'
type_ind <- match(type, c('point', 'line', 'other'))
defaults <- list(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to re-think this at some point in order to expose to the user in the same way as other geoms. But we don't need to do that in this PR.

@lock

lock Bot commented Sep 1, 2019

Copy link
Copy Markdown

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock Bot locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants