crazycapivara / deckgl

An R Interface to deck.gl
https://crazycapivara.github.io/deckgl/
Other
90 stars 11 forks source link

add_polygon_layer incompatible with sf #222

Open sdamerdji opened 9 months ago

sdamerdji commented 9 months ago

Documentation claims:

An object of class sf is a data.frame with a geometry list-column. Set the layer prop that fetches the geometry to the geometry list-column of your sf object:

# Example: PolygonLayer

props <- list(
  getPolygon = ~geometry
  # ...
)

This R script shows this is not the case.

library(sf)
library(deckgl)

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

deck <- deckgl() %>%
  add_polygon_layer(
    data = nc,
    properties = list(getPolygon = ~geometry)
    ) %>%
  add_basemap()

if (interactive()) deck

When opened and inspected in the browser, there is the following error "deck: error during initialization of PolygonLayer({id: 'polygon-layer'}) Error: invalid polygon"

sdamerdji commented 9 months ago

I see now a workaround was posted here https://github.com/crazycapivara/deckgl/issues/178#issuecomment-962519169

Please kindly fix the documentation

kmcd39 commented 4 months ago

Seconding this! Was confused