-
Notifications
You must be signed in to change notification settings - Fork 59
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
geojsonio::geojson_json call leads to Error: protect(): protection stack overflow #128
Comments
oof, sorry about that @sheffe I ran the examle, and indeed get the same thing. looking into it. |
@sckott I also noticed that converting big |
thanks @ateucher - sounds good.
possibly, will have to make sure it wouldn't break behavior. |
I don't know enough about C++ to know whether this is related to the protect/stackoverflow issues, but here is a test of timings with a largish library(bcmaps)
library(geojsonio)
bc <- bc_bound_hres()
system.time(geojson_json(bc))
#> user system elapsed
#> 14.949 1.864 29.755
# View source
geojsonio:::geojson_json.sf
#> function (input, lat = NULL, lon = NULL, group = NULL, geometry = "point",
#> type = "auto", convert_wgs84 = FALSE, crs = NULL, ...)
#> {
#> geoclass(as.json(geojson_list(input, convert_wgs84 = convert_wgs84,
#> crs = crs), ...), type)
#> }
#> <environment: namespace:geojsonio>
# We can remove the `geoclass` function to see how fast it is without that:
system.time(as.json(geojson_list(bc)))
#> user system elapsed
#> 3.327 0.145 5.866 |
@sckott as a way around it, could we either:
|
If option 2, the geoclass <- function(x, type = "FeatureCollection") {
res <- switch(type,
"auto" = geojson::to_geojson(unclass(x)),
"Point" = geojson::point(unclass(x)),
"LineString" = geojson::linestring(unclass(x)),
"Polygon" = geojson::polygon(unclass(x)),
"MultiPoint" = geojson::multipoint(unclass(x)),
"MultiLineString" = geojson::multilinestring(unclass(x)),
"MultiPolygon" = geojson::multipolygon(unclass(x)),
"Feature" = geojson::feature(unclass(x)),
"FeatureCollection" = geojson::featurecollection(unclass(x)),
"GeometryCollection" = geojson::geometrycollection(unclass(x)),
"character" = unclass(x) # <---- New option to skip the geojsonifying...
)
class(res) <- c(class(res), c("geo_json", "json"))
return(res)
}
|
I guess a |
install from library(bcmaps)
library(geojsonio)
bc <- bc_bound_hres()
system.time(geojson_json(bc, type = "skip"))
#> user system elapsed
#> 1.680 0.093 1.787
system.time(geojson_json(bc))
#> user system elapsed
#> 13.259 1.154 15.823 |
thoughts? |
Makes sense to me. Thanks @sckott ! |
@sckott should we add this to the v0.6.0 milestone? |
@ateucher yep, sounds good, can you do that? or do you not have access? |
Done! |
@ateucher is this now working in |
I’ll check. I had actually circumvented it, but will likely go back to this |
should we leave this open or close? |
Before closing - thanks, everyone! |
Go ahead and close. It’s a rmapshaper issue now ;) |
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
Crosspost at @ateucher 's request from rmapshaper#71 here
I'm working with a moderately sized sf polygon object (all US census tracts downloaded by the tigris package), about 73k rows and 150Mb in memory according to object.size(). I'm using rmapshaper::ms_simplify() with default params, and getting a consistent error of the form Error: protect(): protection stack overflow. Other sf polygon objects work just fine, but they're meaningfully smaller. I'm running MacOS with 64GB RAM and system monitors show relatively low memory usage during runtime. I've tried using rmapshaper::ms_simplify() on the sf object and a conversion with geojsonio::geojson_json() and geojsonio::geojson_list(), all to the same effect.
Andy writes:
This gist has code with reproducible example and devtools::session_info().
The text was updated successfully, but these errors were encountered: