Last active
October 25, 2016 11:32
-
-
Save tim-salabim/74a86010478e279281e58208823506ca to your computer and use it in GitHub Desktop.
view and query millions of points colored by a certain variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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