Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in chapter five, code chunk 6 #1085

Closed
manab-prakash opened this issue Mar 9, 2024 · 8 comments
Closed

Error in chapter five, code chunk 6 #1085

manab-prakash opened this issue Mar 9, 2024 · 8 comments

Comments

@manab-prakash
Copy link

In chapter five, code chunk 6, running following :
us_states_simp2 = rmapshaper::ms_simplify(us_states2163, keep = 0.01,
keep_shapes = TRUE)
gives Error: SyntaxError: Unexpected token '.'

@Nowosad
Copy link
Member

Nowosad commented Mar 9, 2024

Hi @manab-prakash -- I am unable to reproduce your issue. Please try to run the code below and let me know if it fails.

library(spData)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.7.3, PROJ 9.2.1; sf_use_s2() is TRUE
us_states_simp2 = rmapshaper::ms_simplify(us_states, keep = 0.01,
                                          keep_shapes = TRUE)
#> Warning in ms_de_unit(input): Coercing these 'units' columns to class numeric:
#> AREA

Created on 2024-03-09 with reprex v2.0.2

@Robinlovelace
Copy link
Collaborator

Works fine for me too so closing for now.

@manab-prakash
Copy link
Author

manab-prakash commented Mar 11, 2024 via email

@Nowosad
Copy link
Member

Nowosad commented Mar 11, 2024

Have you tried to run the code as one line? This error does not sound like an R error, but an external one...

library(spData)
library(sf)
us_states_simp2 = rmapshaper::ms_simplify(us_states, keep = 0.01, keep_shapes = TRUE)

@Robinlovelace
Copy link
Collaborator

rmapshaper::ms_simplify(us_states, keep = 0.01,+

Could the + be an issue?

@manab-prakash
Copy link
Author

manab-prakash commented Mar 13, 2024 via email

@Nowosad
Copy link
Member

Nowosad commented Mar 13, 2024

Another idea, @manab-prakash -- are you using the current source code of the book? We do not have an object us_states2163 anymore in the book...

@manab-prakash
Copy link
Author

Yes, I tried the newer version too. The result is the same. The source of the error seems to be from C++. It is definitely not an issue from geocompr. The complete traceback is:

traceback()
10: stop(structure(list(message = "SyntaxError: Unexpected token '.'",
call = NULL, cppstack = NULL), class = c("std::invalid_argument",
"C++Error", "error", "condition")))
9: context_eval(join(src), private$context, serialize, await)
8: get_str_output(context_eval(join(src), private$context, serialize,
await))
7: evaluate_js(readLines(file, encoding = "UTF-8", warn = FALSE))
6: ctx$source(system.file("mapshaper/mapshaper-browserify.min.js",
package = "rmapshaper"))
5: ms_make_ctx()
4: apply_mapshaper_commands(data = geojson, command = call, force_FC = TRUE,
sys = sys, sys_mem = sys_mem, quiet = quiet)
3: ms_sf(input, call, ...)
2: ms_simplify.sf(us_states, keep = 0.01, keep_shapes = TRUE)
1: rmapshaper::ms_simplify(us_states, keep = 0.01, keep_shapes = TRUE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants