Code Monkey home page Code Monkey logo

h3jsr's People

Contributors

espinielli avatar mikemahoney218 avatar obrl-soil avatar olivroy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

h3jsr's Issues

CRAN plans / help wanted?

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.

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

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 

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

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.

`test-custom_functions.R` errors if sf adds attributes to sf objects

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:

test_that(
'cell_to_line returns correctly - data.frame with list-column',
c(library(sf),
brisbane_hex_10 <- cell_to_polygon(input = '8abe8d12acaffff'),
hex_sample <- get_disk_list('8abe8d12acaffff', 4)[[1]][[4]][seq(1,18,3)],
hex_sample_polys <- cell_to_polygon(hex_sample),
paths <- grid_path(rep('8abe8d12acaffff', 6), hex_sample),
paths_df <- data.frame('ID' = seq(6), 'paths' = I(paths)),
val1 <- cell_to_line(paths_df),
val2 <- cell_to_line(paths_df, simple = FALSE),
expect_is(val1, 'sfc_LINESTRING'),
expect_length(val1, 6),
expect_is(val2, 'sf'),
expect_equal(ncol(val2), 3),
expect_equal(nrow(val2), 6),
ins <- sf::st_set_geometry(val2, NULL), # wierd behav when lib() missing
expect_identical(ins, paths_df),
expect_is(val2$geometry, 'sfc_LINESTRING')
)
)

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!

cant install obrl-soil/h3jsr

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

ubuntu only bug : h3_to_polygon

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

screen_shot_01

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.