SymbolixAU / mapdeck

R interface to Deck.gl and Mapbox
https://symbolixau.github.io/mapdeck/articles/mapdeck.html
363 stars 40 forks source link

Adding a sf object in add_polygon throws an error #297

Closed dhersz closed 4 years ago

dhersz commented 4 years ago

Bug description Adding a sf object in add_polygon throws an error.

To reproduce

library(mapdeck)

    set_token(Sys.getenv("MAPBOX"))
    ms = mapdeck_style("dark")
    mapdeck(style = ms, pitch = 45, location = c(0, 52), zoom = 4) %>%
        add_polygon(data = spData::lnd, layer_id = "london")
#> Error in rcpp_cast_sf(sf, to, close): Not compatible with requested type: [type=character; target=integer].

Expected A london map.

Version mapdeck_0.3.2

trafficonese commented 4 years ago

it works for me, with the same mapdeck version.

dcooley commented 4 years ago

fine for me too.

Can I see you devtools::session_info("mapdeck") ?


mapdeck(
  style = ms
  , pitch = 45
  ) %>%
  add_polygon(
    data = spData::lnd
    , layer_id = "london"
    , fill_colour = "HECTARES"
    , legend = TRUE
    )
Screenshot 2020-05-01 at 7 05 50 am
dhersz commented 4 years ago

Sure:

> devtools::session_info("mapdeck")
- Session info -----------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.6.1 (2019-07-05)
 os       Windows 10 x64              
 system   x86_64, mingw32             
 ui       RStudio                     
 language (EN)                        
 collate  Portuguese_Brazil.1252      
 ctype    Portuguese_Brazil.1252      
 tz       America/Sao_Paulo           
 date     2020-04-30                  

- Packages ---------------------------------------------------------------------------------------
 package         * version  date       lib source        
 BH                1.72.0-3 2020-01-08 [1] CRAN (R 3.6.2)
 colourvalues      0.3.4    2020-03-18 [1] CRAN (R 3.6.3)
 crayon            1.3.4    2017-09-16 [1] CRAN (R 3.6.3)
 curl              4.3      2019-12-02 [1] CRAN (R 3.6.3)
 digest            0.6.25   2020-02-23 [1] CRAN (R 3.6.3)
 fastmap           1.0.1    2019-10-08 [1] CRAN (R 3.6.3)
 geojsonsf         1.3.3    2020-03-18 [1] CRAN (R 3.6.3)
 googlePolylines   0.7.2    2018-11-23 [1] CRAN (R 3.6.3)
 htmltools         0.4.0    2019-10-04 [1] CRAN (R 3.6.3)
 htmlwidgets       1.5.1    2019-10-08 [1] CRAN (R 3.6.3)
 httpuv            1.5.2    2019-09-11 [1] CRAN (R 3.6.3)
 jsonify           1.1.1    2020-03-14 [1] CRAN (R 3.6.3)
 jsonlite          1.6.1    2020-02-02 [1] CRAN (R 3.6.3)
 later             1.0.0    2019-10-04 [1] CRAN (R 3.6.3)
 magrittr          1.5      2014-11-22 [1] CRAN (R 3.6.3)
 mapdeck         * 0.3.2    2020-04-05 [1] CRAN (R 3.6.3)
 mime              0.9      2020-02-04 [1] CRAN (R 3.6.2)
 promises          1.1.0    2019-10-04 [1] CRAN (R 3.6.3)
 R6                2.4.1    2019-11-12 [1] CRAN (R 3.6.3)
 rapidjsonr        1.2.0    2020-03-08 [1] CRAN (R 3.6.3)
 Rcpp              1.0.4.6  2020-04-09 [1] CRAN (R 3.6.3)
 rlang             0.4.5    2020-03-01 [1] CRAN (R 3.6.3)
 sfheaders         0.2.1    2020-03-19 [1] CRAN (R 3.6.3)
 shiny             1.4.0.2  2020-03-13 [1] CRAN (R 3.6.3)
 sourcetools       0.1.7    2018-04-25 [1] CRAN (R 3.6.3)
 spatialwidget     0.2.2    2020-03-21 [1] CRAN (R 3.6.3)
 xtable            1.8-4    2019-04-21 [1] CRAN (R 3.6.3)
 yaml              2.2.1    2020-02-01 [1] CRAN (R 3.6.2)

[1] C:/Users/Usuario/Documents/R/win-library/3.6
[2] C:/Program Files/R/R-3.6.1/library
dcooley commented 4 years ago

nothing there seems like it would cause any issues.

The specific error you're seeing is from sfheaders::sf_cast() Could you try installing the latest dev version of that, and then update mapdeck:

## restart your session, then
remotes::install_github("dcooley/sfheaders")
remotes::install_github("SymbolixAU/mapdeck")
dhersz commented 4 years ago

It worked after updating the packages. Thanks!