Skip to content

Instantly share code, notes, and snippets.

@tim-salabim
Last active October 25, 2016 11:32
Show Gist options
  • Save tim-salabim/74a86010478e279281e58208823506ca to your computer and use it in GitHub Desktop.
Save tim-salabim/74a86010478e279281e58208823506ca to your computer and use it in GitHub Desktop.
view and query millions of points colored by a certain variable
#devtools::install_github("environmentalinformatics-marburg/mapview", ref = "develop")
library(mapview)
library(sp)
library(raster)
library(ggplot2)
### blow diamonds up a bit (change number of repeats - 20 - to blow up more or less)
big <- data.frame(diamonds[rep(seq_len(nrow(diamonds)), 20),])
big$cut <- as.character(big$cut)
big$color <- as.character(big$color)
big$clarity <- as.character(big$clarity)
### provide some random positions
big$x <- rnorm(nrow(big), 0, 10)
big$y <- rnorm(nrow(big), 0, 10)
coordinates(big) <- ~x+y
proj4string(big) <- CRS("+init=epsg:4326")
### view it
mapview(big, zcol = "cut")
### or setup leaflet
leaflet() %>%
addProviderTiles("CartoDB.Positron") %>%
addMouseCoordinates()%>%
addHomeButton(extent(big), "test2") %>%
addScaleBar("bottomleft") %>%
mapview:::addVeryLargePoints(big, zcol = "cut")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment