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
library(leaflet) | |
library(mapview) | |
spatial_merge <- gadmCHE | |
m1 <- leaflet() %>% | |
addTiles() %>% | |
addPolygons(data = spatial_merge, | |
layerId = spatial_merge@data$OBJECTID, | |
stroke= TRUE, fillOpacity = 0.5, smoothFactor = 0.5, weight=1, |
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) |
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("rstudio/leaflet", force = TRUE) | |
library(leaflet) | |
library(sf) | |
### polygons -------------------------------------------------------------- | |
poldata <- st_as_sf(mapview::gadmCHE) | |
class(poldata) | |
class(st_geometry(poldata)) | |
class(st_geometry(poldata)[[1]]) |
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
library(sf) | |
library(mapview) | |
library(foreign) | |
tst <- read_sf("software/data/NUTS_2013_01M_SH/data/NUTS_RG_01M_2013.shp") | |
db <- read.dbf("software/data/NUTS_2013_01M_SH/data/NUTS_AT_2013.dbf") | |
tst_db <- merge(tst, db, by = "NUTS_ID") | |
tst_db5 <- tst_db[nchar(as.character(tst_db$NUTS_ID)) == 5, ] |
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
library(sf) | |
library(mapview) | |
library(data.table) | |
lns = st_cast(trails, "LINESTRING") | |
# lns = lns[rep(seq_len(nrow(lns)), 1000),] | |
pts = st_cast(st_line_sample(lns, n = 1), "POINT") | |
st_explode = function(x) { | |
if (!inherits(st_geometry(x), "sfc_LINESTRING")) |
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
#include <Rcpp.h> | |
#include <math.h> | |
using namespace Rcpp; | |
// helper functions to convert degrees to radians and vice versa ============= | |
// [[Rcpp::export]] | |
double deg(double radians) { | |
return 180 * radians / M_PI; | |
} |
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
library(mapview) | |
library(sf) | |
xyGrid = function(x) { | |
# x = iris_sf | |
xrange = mapview:::extendLimits(c(st_bbox(x)[["xmin"]], st_bbox(x)[["xmax"]])) | |
yrange = mapview:::extendLimits(c(st_bbox(x)[["ymin"]], st_bbox(x)[["ymax"]])) | |
xticks = pretty(xrange) |
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
library(mapview) | |
library(leaflet.minicharts) | |
library(sf) | |
val1 = sample.int(10, nrow(franconia), replace = TRUE) | |
val2 = round(val1 * runif(nrow(franconia), 0.3, 1), 0) | |
mat = cbind(val1, val2) | |
pal = c("darkred", "lightgreen") |
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
library(mapview) | |
library(sf) | |
## create polygon index column | |
franconia$index = sprintf("%02.f", 1:nrow(franconia)) | |
## join polygons to points | |
brew_franc = st_join(breweries, franconia[, c("index", "geometry")]) | |
## split on polygon entity |
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
## helper functions to convert degrees to radians and vice versa ============= | |
deg_r = function(radians) { | |
180 * radians / pi | |
} | |
rad_r = function(degrees) { | |
degrees * pi / 180 | |
} |
OlderNewer