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

tbl_df causing errors from encode(sf) #16

Closed
3 tasks done
SymbolixAU opened this issue Jan 29, 2018 · 5 comments
Closed
3 tasks done

tbl_df causing errors from encode(sf) #16

SymbolixAU opened this issue Jan 29, 2018 · 5 comments
Labels

Comments

@SymbolixAU
Copy link
Collaborator

SymbolixAU commented Jan 29, 2018

This comes from sf::read_sf("/sf/file/.shp"), which builds it using a tibble.

But, sf::st_read() is fine...


TODO

  • test on googleway
  • test on mapdeck
  • include a test for custom classes (and tibble!)
@mdsumner
Copy link

Just to note that read_sf also defaults to stringsAsFactors = FALSE (mainly why I use it), and can be passed to st_read for a vanilla data.frame with character vars.

Most problems I see with tibbles are about [,1] being assumed to drop = TRUE for a vanilla data frame.

@SymbolixAU
Copy link
Collaborator Author

@mdsumner timely response; I've just been reading the various discussions on r-spatial/sf about this.

I don't think this will be a difficult solve, just need to get motivated to do it. Mainly because all my work is in data.table and not the tidyverse.

@mdsumner
Copy link

Cool, didn't think I had much to add - just making sure. It's clarified and galvanized somewhat for me in the last couple of years ;)

I wasn't thinking of data.table, so appreciate hearing that that impacts your views. I need to be more aware of its relationships here.

@SymbolixAU
Copy link
Collaborator Author

Likewise; I need to be more aware of what the rest of the world use :)

@SymbolixAU SymbolixAU self-assigned this Aug 19, 2018
@SymbolixAU SymbolixAU added the bug label Aug 19, 2018
SymbolixAU pushed a commit that referenced this issue Aug 20, 2018
@SymbolixAU
Copy link
Collaborator Author

fix is inbound on branch tbldf

library(sf)
library(googlePolylines)

df_nc <- sf::st_read(system.file("shape/nc.shp", package="sf"))
tbl_nc <- sf::read_sf(system.file("shape/nc.shp", package="sf"))

enc_nc <- encode(df_nc)
enc_tbl <- encode(tbl_nc)
enc_tbl_lite <- encode(tbl_nc, strip = T)

attr(enc_nc, 'class')
attr(enc_tbl, 'class')
attr(enc_tbl_lite, 'class')

attr(enc_nc[1, ], 'class')
attr(enc_tbl[1, ], 'class')

library(googleway)

set_key("GOOGLE_MAP_KEY")

google_map() %>%
  add_polygons(data = df_nc)

google_map() %>%
  add_polygons(data = tbl_nc)

SymbolixAU pushed a commit that referenced this issue Aug 24, 2018
@SymbolixAU SymbolixAU removed their assignment Jan 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant