{"action":"created","issue":{"url":"https://api.github.com/repos/edzer/sfr/issues/131","repository_url":"https://api.github.com/repos/edzer/sfr","labels_url":"https://api.github.com/repos/edzer/sfr/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/edzer/sfr/issues/131/comments","events_url":"https://api.github.com/repos/edzer/sfr/issues/131/events","html_url":"https://github.com/edzer/sfr/issues/131","id":197170642,"number":131,"title":"Error on st_union() in summarise()","user":{"login":"etiennebr","id":393576,"avatar_url":"https://avatars.githubusercontent.com/u/393576?v=3","gravatar_id":"","url":"https://api.github.com/users/etiennebr","html_url":"https://github.com/etiennebr","followers_url":"https://api.github.com/users/etiennebr/followers","following_url":"https://api.github.com/users/etiennebr/following{/other_user}","gists_url":"https://api.github.com/users/etiennebr/gists{/gist_id}","starred_url":"https://api.github.com/users/etiennebr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/etiennebr/subscriptions","organizations_url":"https://api.github.com/users/etiennebr/orgs","repos_url":"https://api.github.com/users/etiennebr/repos","events_url":"https://api.github.com/users/etiennebr/events{/privacy}","received_events_url":"https://api.github.com/users/etiennebr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-12-22T13:06:13Z","updated_at":"2016-12-22T21:23:19Z","closed_at":null,"body":"`st_union()` seem to work fine, but in `summarise()` it creates a weird geometry that it can't read. I tried to dump the geometry to wkt (quite large, so I won't put it here), and it can display on [wicket](http://arthur-e.github.io/Wicket/sandbox-gmaps3.html), but vertex order is slightly wrong. I think it might be how it handled the multi parts polygons.\r\n\r\n```r\r\nlibrary(dplyr)\r\nlibrary(tibble)\r\n\r\nnc <- st_read(system.file(\"shape/nc.shp\", package=\"sf\"))\r\n\r\nnc %>%\r\n  st_area() %>%\r\n  sum\r\n# 127031757146 m^2\r\n\r\nas(nc$geometry, \"Spatial\") %>% \r\n  rgeos::gUnionCascaded(nc$SID79) %>%\r\n  st_as_sf() %>% \r\n  st_area %>% \r\n  sum\r\n# 127031757076 m^2\r\n\r\nx <- lapply(unique(nc$SID79), function(i) {\r\n  nc %>%\r\n    dplyr::filter(SID79 == i) %>% \r\n    summarise(geog = st_union(geometry), area = st_area(geog))\r\n})\r\n# It would be nice to have something like row_bind(x) %>% st_area() %>% sum()\r\nsum(sapply(x, function(x) x[[\"area\"]]))\r\n# [1] 127031757146\r\n\r\nnc %>%\r\n  ungroup() %>%\r\n  summarise(geog = st_union(geometry), area = st_area(geog))\r\n#                             geog             area\r\n# 1 MULTIPOLYGON(((-76.54427337... 127031757146 m^2\r\n```\r\n\r\nBut it fails with summarise\r\n```r\r\nnc %>%\r\n  group_by(SID79) %>% \r\n  summarise(geog = st_union(geometry), area = st_area(geog))\r\n# Error in summarise_impl(.data, dots) : \r\n# no applicable method for 'st_geometry' applied to an object of class \"list\" \r\n```\r\n\r\nTo dump the geometry: \r\n```r\r\nnc %>% as_tibble %>%\r\n  group_by(SID79) %>% \r\n  summarise(geog = st_union(geometry)) %$%\r\n  st_as_text(geog) %>%\r\n  cat(file=\"geog.wkt\")\r\n```"},"comment":{"url":"https://api.github.com/repos/edzer/sfr/issues/comments/268893511","html_url":"https://github.com/edzer/sfr/issues/131#issuecomment-268893511","issue_url":"https://api.github.com/repos/edzer/sfr/issues/131","id":268893511,"user":{"login":"edzer","id":520851,"avatar_url":"https://avatars.githubusercontent.com/u/520851?v=3","gravatar_id":"","url":"https://api.github.com/users/edzer","html_url":"https://github.com/edzer","followers_url":"https://api.github.com/users/edzer/followers","following_url":"https://api.github.com/users/edzer/following{/other_user}","gists_url":"https://api.github.com/users/edzer/gists{/gist_id}","starred_url":"https://api.github.com/users/edzer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edzer/subscriptions","organizations_url":"https://api.github.com/users/edzer/orgs","repos_url":"https://api.github.com/users/edzer/repos","events_url":"https://api.github.com/users/edzer/events{/privacy}","received_events_url":"https://api.github.com/users/edzer/received_events","type":"User","site_admin":false},"created_at":"2016-12-22T21:23:19Z","updated_at":"2016-12-22T21:23:19Z","body":"I don't understand the `traceback()` of that."}}
{"actor":{"display_login":"edzer"}}