-
Notifications
You must be signed in to change notification settings - Fork 0
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
Reduce spatial data size #11
Comments
There, |
Wups, actually htmlwidgets uses a wrapper for options(htmlwidgets.TOJSON_ARGS = list(pretty = TRUE, digits = 6)) |
This gets it down to ~3.2MB in browser and 2MB for the file system size. Good enough for twitter card validation. Another thing is that the html labels are repeated for each |
The index page (
index.html
) is quite big. I started out at almost 6MB when loaded in a browser, and through playing around withst_simplify()
for the two map objects I can get it down to around 4.53 MB when loaded. This still doesn't work with the Twitter card validator (see #10), and reducing the number of points further at this point I think will detract too much visibly.Another option might be to reduce the precision of the coordinates.
Right now
index.html
stores the coordinates like "-0.456945916095746", i.e. with 15 digits. That's probably way more than needed. (These are lag/long coordinates, so range from -180 - 180 and -90 to 90.)So try this instead: reduce number of digits in the coordinates (and probabilities, for that matter); and possible maybe try to revert the point reduction (
st_simplify()
) back to the earlier values.In rleaflet, for sf, the code to convert sf to GeoJSON straight pulls from the sf coordinates, see https://github.com/rstudio/leaflet/blob/master/R/normalize-sf.R.
sf has a set of precision functions, but these only come into play when writing out data (see https://r-spatial.github.io/sf/reference/st_precision.html). rleafet's straight access to the sf coordinates thus circumvents this. Maybe either:
rleaflet::sf_coords()
sf
to GeoJSON; manipulate the coordinates somehow, and then add it as a GeoJSON layer in leaflet.The text was updated successfully, but these errors were encountered: