Title: plotly not plotting sf multipolygon objects · Issue #1659 · plotly/plotly.R · GitHub
Open Graph Title: plotly not plotting sf multipolygon objects · Issue #1659 · plotly/plotly.R
X Title: plotly not plotting sf multipolygon objects · Issue #1659 · plotly/plotly.R
Description: I am trying to use plotly to create interactive maps using a multipolygon sf object as the input. I am able to get a plotly map using one dataset, and when I compare to the dataset I am interested in, they appear to be of the same class,...
Open Graph Description: I am trying to use plotly to create interactive maps using a multipolygon sf object as the input. I am able to get a plotly map using one dataset, and when I compare to the dataset I am interested ...
X Description: I am trying to use plotly to create interactive maps using a multipolygon sf object as the input. I am able to get a plotly map using one dataset, and when I compare to the dataset I am interested ...
Opengraph URL: https://github.com/plotly/plotly.R/issues/1659
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"plotly not plotting sf multipolygon objects","articleBody":"I am trying to use plotly to create interactive maps using a multipolygon sf object as the input. I am able to get a plotly map using one dataset, and when I compare to the dataset I am interested in, they appear to be of the same class, however I cannot get my dataset working. When I try to plot with the data of interest I get the following error, despite the object actually being a multipolygon sf object:\r\n\r\n`Error in st_coordinates.sfc(model$geometry) : \r\n not implemented for objects of class sfc_GEOMETRYCOLLECTION`\r\n\r\n**Environment:**\r\n- R version: 3.6.1\r\n- Platform: x86_64-pc-linux-gnu (OS: Ubuntu 18.04.3 LTS)\r\n- plotly version: plotly_4.9.0.9000 (dev version)\r\n- sf version: sf_0.8-0\r\n\r\nBelow is a reproducible example that results in the error above:\r\n\r\n```\r\nlibrary(plotly)\r\nlibrary(sf)\r\nlibrary(spData)\r\nplot_ly(world, split = ~iso_a2, color = ~pop)\r\n```\r\n\r\nBelow is a reproducible example that runs successfully:\r\n\r\n```\r\nlibrary(plotly)\r\nlibrary(sf)\r\nlibrary(spData)\r\nnc \u003c- sf::st_read(system.file(\"shape/nc.shp\", package = \"sf\"), quiet = TRUE)\r\nplot_ly(nc, split=~NAME)\r\n```\r\n\r\nWhen I examine each object, I get the following output:\r\n`class(st_geometry(world))`\r\n\r\n[1] \"sfc_MULTIPOLYGON\" \"sfc\"\r\n \r\n`class(st_geometry(nc))`\r\n\r\n\r\n[1] \"sfc_MULTIPOLYGON\" \"sfc\" \r\n\r\nI have tried running the following, to investigate the error message and get the expected matrix of coordinates without error: \r\n\r\n```\r\nworld_coords \u003c- st_coordinates(world)\r\nhead(world_coords)\r\n```\r\n\r\n X Y L1 L2 L3\r\n[1,] 180.0000 -16.06713 1 1 1\r\n[2,] 180.0000 -16.55522 1 1 1\r\n[3,] 179.3641 -16.80135 1 1 1\r\n[4,] 178.7251 -17.01204 1 1 1\r\n[5,] 178.5968 -16.63915 1 1 1\r\n[6,] 179.0966 -16.43398 1 1 1\r\n\r\n```\r\nnc_coords \u003c- st_coordinates(nc)\r\nhead(nc_coords)\r\n```\r\n\r\n X Y L1 L2 L3\r\n[1,] -81.47276 36.23436 1 1 1\r\n[2,] -81.54084 36.27251 1 1 1\r\n[3,] -81.56198 36.27359 1 1 1\r\n[4,] -81.63306 36.34069 1 1 1\r\n[5,] -81.74107 36.39178 1 1 1\r\n[6,] -81.69828 36.47178 1 1 1\r\n\r\nIt is unclear to me what the issue is with the `world` dataset, what is different between the `world` and the `nc` dataset, and what is unique to the `nc` dataset that enables plotly plotting. I am able to plot with tmap, thus I do not believe the object itself to be the issue. Any help with this issue is greatly appreciated. \r\n\r\n`tm_shape(world) +\r\n tm_polygons() ` ","author":{"url":"https://github.com/erstearns","@type":"Person","name":"erstearns"},"datePublished":"2019-11-17T00:19:21Z","url":"https://github.com/plotly/plotly.R/issues/1659"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:20688dc5-0e35-a468-1752-f7d759cc304f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B792:A71F9:249891:2DE564:6B00FEB5 |
| html-safe-nonce | 89adf8aabbb0efca3b4ea556bfc411b758b8facc692027b66c2c09a68eff84be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNzkyOkE3MUY5OjI0OTg5MToyREU1NjQ6NkIwMEZFQjUiLCJ2aXNpdG9yX2lkIjoiNjI5MjM0MDM1Mjc0MTM0MjkwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 67c964f917f098f5a749dc299284259f3097ac5122db4d0c6ce6891b6310515d |
| hovercard-subject-tag | issue:523914219 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.R/1659/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0f7f770d622d020df4cce3f10ddfb0e500ba48ba21b1cc7f425a956855ea5473/plotly/plotly.R/issues/1659 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0f7f770d622d020df4cce3f10ddfb0e500ba48ba21b1cc7f425a956855ea5473/plotly/plotly.R/issues/1659 |
| og:image:alt | I am trying to use plotly to create interactive maps using a multipolygon sf object as the input. I am able to get a plotly map using one dataset, and when I compare to the dataset I am interested ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | erstearns |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.R git https://github.com/plotly/plotly.R.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579179 |
| octolytics-dimension-repository_nwo | plotly/plotly.R |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579179 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.R |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width