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

Error in polyfill when using h3jsr::polyfill instead of library(h3jsr) #6

Closed dhersz closed 4 years ago

dhersz commented 4 years ago

Hi.

If instead of loading the package with library(h3jsr) one uses h3jsr::polyfill an error is thrown:

hex_ids <- h3jsr::polyfill(spData::nz, res = 7)
#> Warning in utils::data("h3_info_table", envir = environment()): data set
#> 'h3_info_table' not found
#> Error in h3jsr::polyfill(spData::nz, res = 7): object 'h3_info_table' not found

When using library(h3jsr):

library(h3jsr)

hex_ids <- polyfill(spData::nz, res = 7)
#> Resolution is very small relative to input dataset. This might take a while...
#> Data has been transformed to EPSG:4326.

The problem seems to be in the usage of " in utils::data("h3_info_table", envir = environment()). The following code works (the warning is still sent though):

data(h3_info_table, package = "h3jsr")
hex_ids <- h3jsr::polyfill(spData::nz, res = 7)
#> Warning in utils::data("h3_info_table", envir = environment()): data set
#> 'h3_info_table' not found
#> Resolution is very small relative to input dataset. This might take a while...
#> Data has been transformed to EPSG:4326.
obrl-soil commented 4 years ago

Oh true. The issue was actually that utils::data couldn't find h3jsr on the search path since it wasn't attached. Its now explicitly referenced wherever h3_info_table is called, so reinstall and you should be good to go.