obrl-soil / h3jsr

Access Uber's h3-js library via R and V8 - https://uber.github.io/h3/#/documentation/overview/use-cases
https://obrl-soil.github.io/h3jsr/
Other
67 stars 5 forks source link

"TypeError: undefined is not a function" in polyfill() #7

Closed mwip closed 4 years ago

mwip commented 4 years ago

When running this (reproducible) code:

library(h3jsr) # remotes::install_github("obrl-soil/h3jsr", force = TRUE)
library(sf)

# read the shapefile of the polygon area you're interested in
de <- raster::getData(country = "DE", level = 0)
de <- st_as_sf(de)
# projection
de <- st_transform(de, crs = 4326)

# get the unique h3 ids of the hexagons intersecting your polygon at a given resolution
de_h3_5 <- polyfill(geometry = de, res = 3)

I get the following error:

Error in context_eval(join(src), private$context, serialize) : 
TypeError: undefined is not a function

I tried to figure out what the issue is (though I am not familiar with node/V8) and it seems to be the case that h3 is not loaded correctly in .onload() or sesh is not extablished correctly.

I acknowledge that this might be caused by improper setup on my side. If that is the case I'd be glad to help testing and reviewing any documentation on a proper setup.

Session info:

``` R version 3.6.3 (2020-02-29) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 18.04.4 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1 locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=de_DE.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] sf_0.9-4 h3jsr_1.1.2 loaded via a namespace (and not attached): [1] Rcpp_1.0.5 pillar_1.4.4 compiler_3.6.3 class_7.3-17 tools_3.6.3 lattice_0.20-41 [7] jsonlite_1.7.0 lifecycle_0.2.0 tibble_3.0.2 gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.6 [13] DBI_1.1.0 rstudioapi_0.11 curl_4.3 e1071_1.7-3 dplyr_1.0.0 raster_3.1-5 [19] generics_0.0.2 vctrs_0.3.1 classInt_0.4-3 grid_3.6.3 tidyselect_1.1.0 glue_1.4.1 [25] geojsonsf_2.0.0 R6_2.4.1 sp_1.4-2 ggplot2_3.3.2 purrr_0.3.4 tidyr_1.1.0 [31] magrittr_1.5 codetools_0.2-16 scales_1.1.1 ellipsis_0.3.1 units_0.6-7 colorspace_1.4-1 [37] V8_3.2.0 KernSmooth_2.23-17 munsell_0.5.0 crayon_1.3.4 ```

obrl-soil commented 4 years ago

Hi, sounds similar to issue #5 - have you looked at updating libv8?

mwip commented 4 years ago

That was infact the problem. Thanks. I was stuck in some weird apt package cycle (yay ubuntu :P) with libnode-dev and npm which conflict...