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

aggregate functions for data.frames with ID columns #32

Open
SymbolixAU opened this issue May 20, 2019 · 1 comment
Open

aggregate functions for data.frames with ID columns #32

SymbolixAU opened this issue May 20, 2019 · 1 comment

Comments

@SymbolixAU
Copy link
Collaborator

for example, googleway can accept lines denoted with an 'id' value.

df <- data.frame(myId = c(1,1,1,1,1,1,2,2,2),
      lineId = c(1,1,1,2,2,2,1,1,1),
      lat = c(26.774, 18.466, 32.321, 28.745, 29.570, 27.339, 22, 23, 22),
      lon = c(-80.190, -66.118, -64.757, -70.579, -67.514, -66.668, -50, -49, -51),
      colour = c(rep("#00FF0F", 6), rep("#FF00FF", 3)),
      stringsAsFactors = FALSE)
@SymbolixAU
Copy link
Collaborator Author

Can use sfheaders for this

sf <- sfheaders::sf_polygon(df, x = "lon", y = "lat", polygon_id = "myId", linestring_id = "lineId")
sf <- merge(
  x = sf
  , y = unique( df[, c("myId", "colour")] )
  , by.x = "id"
  , by.y = "myId"
)

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

0 participants