This file contains hidden or 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
| install.packages("drat") | |
| drat::addRepo("rcourses") | |
| install.packages("nclRadvanced", type="source") |
This file contains hidden or 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
| x <- 1:99 | |
| y = x^2 / exp(x) | |
| plot(x, y) | |
| pkgs <- c("downloader", "readxl") | |
| install.packages(pkgs) | |
| lapply(pkgs, library, character.only = T) | |
| dir.create("big-data") | |
| download("http://tinyurl.com/r-for-bd-8", |
This file contains hidden or 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
| # Households with a car and no professionals | |
| synhhlds <- c(synhhlds, | |
| sample( | |
| filter(hhlds, | |
| numprof == 0, | |
| numcars > 0 | |
| )$hhld, | |
| popdist['Car','Other']) | |
| ) |
This file contains hidden or 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
| # # # # # # # # # # # # # # # # # # # # | |
| # Simplify sp objects w. mapshaper # | |
| # Needs https://nodejs.org installed # | |
| # Tested on Windows and Linux # | |
| # # # # # # # # # # # # # # # # # # # # | |
| # # # # # # | |
| # R setup # | |
| # # # # # # |
This file contains hidden or 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
| # Aim: illustrate how to invert a spatial subset | |
| # load the sp library and data | |
| library(sp) | |
| data("meuse") | |
| coordinates(meuse) = ~x+y | |
| data("meuse.riv") | |
| meuse.sr = SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv"))) | |
| # plot the basics |
This file contains hidden or 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
| download.file("https://www.geofabrik.de/data/shapefiles_toulouse.zip", "shapefiles_toulouse.zip") | |
| unzip("shapefiles_toulouse.zip") | |
| system.time({ | |
| shp = rgdal::readOGR(dsn = ".", layer = "gis.osm_buildings_v06") | |
| }) | |
| f = list.files(pattern = "gis.osm") | |
| file.remove(f) | |
| file.remove("shapefiles_toulouse.zip") |
This file contains hidden or 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(magick) | |
| library(magrittr) | |
| # create raster layers | |
| oldlogo <- image_read("https://developer.r-project.org/Logo/Rlogo-2.png") | |
| newlogo <- image_read("https://www.r-project.org/logo/Rlogo.png") | |
| oldlogo_blue = image_colorize(image = oldlogo, opacity = 99, color = "blue") %>% | |
| image_blur(radius = 10, sigma = 10) | |
| newlogo_red = image_colorize(image = newlogo, opacity = 99, color = "red") %>% | |
| image_blur(radius = 10, sigma = 10) %>% | |
| image_rotate(degrees = 90) |
This file contains hidden or 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(stplanr) | |
| d = SpatialPoints(coords = matrix(rnorm(100), ncol = 2)) | |
| b = bb2poly(bb = d) | |
| p = raster::geom(b) | |
| for(i in 1:4){ | |
| if(i == 1) | |
| l = raster::spLines(rbind(p[i, c("x", "y")], p[i + 1, c("x", "y")])) else | |
| l = raster::bind( | |
| l, | |
| raster::spLines(rbind(p[i, c("x", "y")], p[i + 1, c("x", "y")])) |
This file contains hidden or 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
| # Aim: reproduce Geocomputation with R book | |
| if(!require(devtools)) { | |
| install.packages("devtools") | |
| } | |
| devtools::install_github("robinlovelace/geocompr") | |
| download.file("https://github.com/Robinlovelace/geocompr/archive/master.zip", "master.zip") | |
| unzip("master.zip") | |
| old_dir = setwd("geocompr-master/") | |
| bookdown::render_book("index.Rmd") # to build the book | |
| browseURL("_book/index.html") # to view it |
This file contains hidden or 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
| x = 1:9 | |
| y = x^2 | |
| cor(x, y) |