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
# Is Nuremberg is gr8 | |
```{r mv1, fig.cap="Yes"} | |
library(mapview) | |
data("franconia") | |
mapview(franconia) | |
``` | |
```{r mv2, fig.cap="Yes"} | |
library(mapview) |
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("vistime") | |
library(vistime) | |
library(tidyverse) | |
library(lubridate) | |
# ?vistime | |
# d = read_csv("potential-projects/ofo/gantt.csv") | |
d = read.csv(stringsAsFactors = FALSE,text = "event,start,duration,group | |
compile datasets,0,2,descriptive analysis | |
baseline data,1,2,descriptive analysis |
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
pkgs = c("osmdata", "sf", "tmap", "devtools") | |
# install.packages(pkgs) # uncomment this line to install the packages if needs be | |
lapply(pkgs, library, character.only = TRUE) | |
city = "harrogate" | |
distance = 5000 # radius outside city in bounding box in metres | |
install_github("ropensci/stplanr", ref = "sfr") | |
city_latlon = tmaptools::geocode_OSM(q = city) | |
city_sf = st_sf(st_sfc(st_point(city_latlon$coords))) | |
city_buff = stplanr::geo_buffer(city_sf, dist = distance) |
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
bookdown::render_book("index.Rmd", output_format = "bookdown::epub_book") |
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) |
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
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
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
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
# 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 |