obrl-soil / h3jsr Goto Github PK
View Code? Open in Web Editor NEWAccess Uber's h3-js library via R and V8 - https://uber.github.io/h3/#/documentation/overview/use-cases
Home Page: https://obrl-soil.github.io/h3jsr/
License: Other
Access Uber's h3-js library via R and V8 - https://uber.github.io/h3/#/documentation/overview/use-cases
Home Page: https://obrl-soil.github.io/h3jsr/
License: Other
Hi there!
As currently written, test-custom_functions.R
is partially testing that the underlying sf object never changes. Specifically, the expect_identical()
here (second to last) will throw errors if sf ever changes the attributes attached to sf objects:
h3jsr/tests/testthat/test_custom_functions.R
Lines 35 to 54 in 9ee5b62
The issue is that by using expect_identical()
, testthat is partially testing if your objects contain exactly the same attributes. Because you're comparing against old saved sf objects, that means you're partially testing internal implementation details of the sf object that aren't guaranteed to remain the same over time. There's a bit more about how testing the attributes of objects created by other packages can be a problem on the Tidyverse blog.
At the moment, we're trying to add a new attribute to sf objects, which causes these tests to error. I'm writing to ask if you'd consider changing these tests to allow sf to improve the internal structure of sf objects.
I believe this test is looking to confirm that the ID and paths of these two objects are equal to each other. Would it be possible to change this test to expect_equal()
with the check.attributes
argument set to FALSE
?
expect_equal(ins, paths_df, check.attributes = FALSE)
This change would mean this package is no longer blocking sf from making changes to the internal structure of sf objects, and would fix the immediate issue with the new attribute.
If you're open to it, I'd be happy to send you a PR to make these changes!
caution :
Windows10, macOS works fine.
error occurs only with ubuntu 18.04 lts.
> h3_to_polygon(input = '8730e1caeffffff')
# Error in context_eval(join(src), private$context, serialize) :
# TypeError: undefined is not a function
> is_valid('8730e1caeffffff')
# [1] TRUE
ironically example script works fine
my session info
> sessionInfo()
R version 3.4.4 (2018-03-15)
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
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] h3jsr_1.1.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 magrittr_1.5 units_0.6-6 tidyselect_1.0.0
[5] R6_2.4.1 rlang_0.4.6 dplyr_0.8.5 tools_3.4.4
[9] grid_3.4.4 KernSmooth_2.23-15 e1071_1.7-3 DBI_1.1.0
[13] ellipsis_0.3.0 class_7.3-14 assertthat_0.2.1 lifecycle_0.2.0
[17] tibble_3.0.1 crayon_1.3.4 sf_0.9-2 purrr_0.3.4
[21] tidyr_1.0.2 vctrs_0.2.4 curl_4.3 glue_1.4.0
[25] geojsonsf_1.3.3 V8_3.0.2 pillar_1.4.4 compiler_3.4.4
[29] classInt_0.4-3 jsonlite_1.6.1 pkgconfig_2.0.3
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.
I get "free(): invalid pointer
Aborted (core dumped)
ERROR: lazy loading failed for package ‘h3jsr’"
remotes::install_github("obrl-soil/h3jsr")
Downloading GitHub repo obrl-soil/h3jsr@HEAD
heavy_check_mark checking for file ‘/tmp/RtmpfcxHni/remotes2c1f20bdc16c/obrl-soil-h3jsr-3d2b654/DESCRIPTION’ ...
─ preparing ‘h3jsr’:
heavy_check_mark checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘h3jsr_1.2.0.tar.gz’
Installing package into ‘/home/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
installing source package ‘h3jsr’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
free(): invalid pointer
Aborted (core dumped)
ERROR: lazy loading failed for package ‘h3jsr’
removing ‘/home/R/x86_64-pc-linux-gnu-library/4.0/h3jsr’
Fehler: Failed to install 'h3jsr' from GitHub:
(konvertiert von Warnung) installation of package ‘/tmp/RtmpfcxHni/file2c1f47b0862a/h3jsr_1.2.0.tar.gz’ had non-zero exit status
Are there any significant blockers stopping this from going to CRAN?
We're using this a lot at work, I'd be happy to pitch in to get it there.
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.
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
But the code that kills it works fine outside of the build process afaict. See https://travis-ci.com/obrl-soil/h3jsr/builds/121067249
As of bug[ #103 (https://github.com/uber/h3-js/issues/103) in H3-js
Inconsistent results from polyfill after calling polyfill with complex polygon crossing antimeridian
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.