How to create a booklet map with thousands of stamps that don't break my browser?

I use the booklet package in R to create a map with a lot of circles on it. A goal is a map that I can publish on my website. The problem that I am facing is that as the number of laps increases, the resulting map loads very slowly, I get a “refractory script” warning and ultimately freezes my browser completely.

I know this is possible because I found a flyer card that works the way I want mine to work:

http://cartologic.com/geoapps/map_viewer/5/ny-crimes-2014-dot-density-map

I noticed on the map above that the circles don't appear as “clickable” like the circles on my map, and that they seem to load into square pieces. I have a suspicion that these things are related to my problem. Unfortunately, I am too new to flyer / javascript materials to figure it out on my own.

Here is a toy example illustrating my problem:

library("leaflet") library("htmlwidgets") dots <- data.frame(x=c(runif(10000, -93.701281, -93.533053)), y=c(runif(10000, 41.515962, 41.644369))) m <- leaflet(dots) %>% addTiles('http://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png') %>% setView(-93.617167, 41.580166, zoom = 12) %>% addCircles(~x, ~y, weight = 1, radius = 5, color = "#FFA500", stroke = TRUE, fillOpacity = 0.1) m saveWidget(widget = m, file="example.html", selfcontained = TRUE) 
+6
source share
3 answers

mapview can help you here. It is based on a flyer library for small datasets, but uses special javascript functions for big data.

your example with 1 Mio. indicates:

 library(mapview) library(sp) dots <- data.frame(x=c(runif(1000000, -93.701281, -93.533053)), y=c(runif(1000000, 41.515962, 41.644369))) coordinates(dots) <- ~ x + y proj4string(dots) <- "+init=epsg:4326" mapview(dots) 

It may take some time to render, but after displaying it, it should be quite responsive. Please note that mapview is designed to work with spatial * objects, so we need calls to set the coordinate slot and projection.

For more information see here:

http://environmentalinformatics-marburg.imtqy.com/web-presentations/20150723_mapView.html

Hope this helps.

+2
source

If you want to add a large number of vector objects to the map, this can rarely be done easily.

Note that raster data is tiled so that all information should not be displayed at a time. For your vector data (in this case circles) you must do the same.

Basically, what I like to do is split a large dataset into smaller (vector) tiles with the same borders as the raster tiles that you display. Duplicate the data if you want it to appear at several zoom levels. When you show a circle, imagine that you are breaking the center points of the circles on the border of the tile.

I have an application like this, where I basically split my vector data at the borders of the tile and save the information in geojson files. When I get an event in which the raster tile is loaded, I can load the equivalent vector file as a geojson layer (the same when the raster tile is unloaded). Thus, you can limit the amount of vector data that should be displayed at any given time.

If you have a lot of glasses, in fact they will not be noticeable at low zoom levels, so it’s better to just show them with the appropriate zoom level (possibly with a different view at small scales - for example, a heat map). This will cause the amount of data to be displayed at any time below.

0
source

Since this question has several upvotes, I will usually describe both solutions that I found. Perhaps if I have time later, I will get all the files along with GitHub.

First I found TileMill. Just load the coordinate data file into TileMill, create the style you want it to appear, and draw the tiles (png). Keep these tiles online somewhere and load them with an elevator. This process was too manual for me because TileMill continued to crash when I loaded into csv files that were too large to render on my machine.

I found that the best solution was to use Processing, adapting Robert Manduca's code here: https://github.com/rmanduca/jobmaps . I do not use Python, so I rewrote these parts in R and changed the processing code according to my specifications.

0
source

All Articles