Skip to content

Better sf support #3164

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

Merged
merged 3 commits into from
Mar 5, 2019
Merged

Better sf support #3164

merged 3 commits into from
Mar 5, 2019

Conversation

thomasp85
Copy link
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
Member

This fixes #2718 at last. Thanks Thomas!

@clauswilke
Copy link
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.

Copy link
Member

@yutannihilation yutannihilation left a comment

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?

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

Choose a reason for hiding this comment

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

Use ", not ', as the style guide says: https://style.tidyverse.org/syntax.html#quotes

Copy link
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 ;-)

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

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
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
Copy link

lock bot commented Sep 1, 2019

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