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

Decode to sf / constructing sfencoded #41

Open
Zedseayou opened this issue May 29, 2019 · 1 comment
Open

Decode to sf / constructing sfencoded #41

Zedseayou opened this issue May 29, 2019 · 1 comment

Comments

@Zedseayou
Copy link

Thanks for this cool package! I currently have a use case where I get given a long vector of polylines, and I'm wondering whether it makes sense to have one of:

  1. A version or option for decode that produces an sf object instead of requiring the user to convert the list of dataframes themselves.
  2. A constructor for sfencoded that does the work of creating an encoded column and sets class so that polyline_wkt %>% st_as_sf can be used.

Both of these are certainly convenience functions. I can try a PR in the next few days once I read over the code a bit also.

@SymbolixAU
Copy link
Collaborator

Number 1 is certainly feasible and I think will just mean attaching sfc attributes here.

We can also add functionality so a data.frame of polylines gets decoded into an sf object.

Example data to work with

polylines <- c(
  "ohlbDnbmhN~suq@am{tAw`qsAeyhGvkz`@fge}A",
  "ggmnDt}wmLgc`DesuQvvrLofdDorqGtzzV"
)

## option to convert to `sfc`
decode(polylines)


df <- data.frame(
  id = 1:2
  , pl = polylines
)

## this will then get converted to `sf`
# decode(df)

For Number 2 are you after

df <- data.frame(
  geom = "POINT(0 1)"
)

sf::st_as_sf(df, wkt = "geom")

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

No branches or pull requests

1 participant