Skip to content
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

popupTable should drop geometry column by default for sf objects #26

Open
davidhodge931 opened this issue Sep 27, 2021 · 4 comments
Open

Comments

@davidhodge931
Copy link

davidhodge931 commented Sep 27, 2021

Currently it only specifies the geometry type for sf objects, which is not that useful or consistent with how it works for sp objects.

library(leaflet)
library(leafpop)

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries91,
                   popup = popupTable(breweries91))

breweries91 <- sf::st_as_sf(breweries91)

leaflet() %>%
  addTiles() %>%
  addCircleMarkers(data = breweries91,
                   popup = popupTable(breweries91))

A way to modify this might be that if it is an sf object, popupTable should relocate geometry to the last col and then default the zcol to be from cols 1 to the second to last col.

  popup_data <- data %>%
      dplyr::relocate(.data$geometry, .after = tidyselect::last_col()) 
  
  popup <- leafpop::popupTable(popup_data, zcol = 1:ncol(popup_data) - 1)
@tim-salabim
Copy link
Member

How bout a drop_geomerty argument (default FALSE to keep the backward compatibility)?

@davidhodge931
Copy link
Author

That sounds good, but it still might not be backward compatible for when people supply an SP object

@tim-salabim
Copy link
Member

Yeah, but at least they can get the same output by setting it ti TRUE. I meant backward more with respect to the current implementation for sf objects. sp will be retired soon anyway, so users will need to switch to sf in any case

@davidhodge931
Copy link
Author

Cool, that'd be fantastic to have that argument @tim-salabim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants