Skip to content

Instantly share code, notes, and snippets.

Timothée Giraud rCarto

Block or report user

Report or block rCarto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View zoom.R
# load libraries
library(sf)
library(cartography)
library(rnaturalearth)
# import world countries and coastlines from Natural Earth
country <- ne_countries(scale = 50, returnclass = "sf",
type="sovereignty")
coastline <- ne_coastline(scale = 50, returnclass = "sf")
View xx.json
This file has been truncated, but you can view the full file.
View reprop.R
legpos <- function(pos, x1, x2, y1, y2, delta1, delta2, legend_xsize, legend_ysize){
# Position
if (pos == "bottomleft") {
xref <- x1 + delta1
yref <- y1 + delta1
}
if (pos == "topleft") {
xref <- x1 + delta1
yref <- y2 - 2 * delta1 - legend_ysize
}
View geocode_adressedatagouvfr.R
library(httr)
adresse <- "8 bd du port"
resultraw <- httr::GET(utils::URLencode(paste0('https://api-adresse.data.gouv.fr/search/?q=', adresse)))
result <-jsonlite::fromJSON(httr::content(resultraw, "text"))
result$features
View addresses.csv
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 6.
"","location","name","housenumber","street","postcode","city","state","country","osm_key","osm_value","lon","lat","msg"
"1","Germany, Augsburg, Berliner Allee 30","Hauptfeuerwache - Berufsfeuerwehr Augsburg","30","Berliner Allee","86153","Augsburg","Bayern","Deutschland","amenity","fire_station",10.9151257435963,48.3738761,NA
"2","Germany, Bautzen, Gesundbrunnenring 23","Feuerwache Bautzen","23","Gesundbrunnenring","02625","Bautzen","Sachsen","Deutschland","amenity","fire_station",14.4383893321343,51.1871298,NA
"3","Germany, Bielefeld, Stadtholz 18","Feuerwache Ost","18","Am Stadtholz","33609","Bielefeld","Nordrhein-Westfalen","Deutschland","amenity","fire_station",8.5537485,52.0256609,NA
"4","Germany, Bochum, Brandwacht 1","Freiwillige Feuerwehr Bochum Brandwacht (LE31)","1","Brandwacht","44894","Bochum","Nordrhein-Westfalen","Deutschland","amenity","fire_station",7.2987397,51.4891521,NA
"5","Germany, Bonn, Lievelingsweg 112","Leitstelle Berufsfeuerwehr Bonn","112","Lievelingsweg","53119","Bonn","Nordrhein-W
View brexit.R
library(sp)
library(raster)
library(rgeos)
## import des données
download.file(url = "http://biogeo.ucdavis.edu/data/gadm2.8/rds/GBR_adm2.rds",
destfile = file.path(tempdir(), "GBR_adm2.rds"))
download.file(url = "http://biogeo.ucdavis.edu/data/gadm2.8/rds/IRL_adm0.rds",
file.path(tempdir(),"IRL_adm0.rds"))
View msd.R
library(cartography)
data("nuts2006")
# GDP par habitants (en euros)
nuts2.df$gdpinh <- 1000000 * nuts2.df$gdppps2008 / nuts2.df$pop2008
boxplot(nuts2.df$gdpinh)
hist(nuts2.df$gdpinh)
rug(nuts2.df$gdpinh)
# Bon d'accord la distribution n'est pas vraiment normale...
View trypar.R
library(SpatialPosition)
load("../LargeSpatialPostition/com.RData")
# création d'une grille fine (5km)
grid <- CreateGrid(w = com, resolution = 5000)
# Les calculs de matrices de distances sont (beaucoup) plus rapides quand les
# objets spatiaux sont en WGS84 :
@rCarto
rCarto / cartomix.R
Last active May 15, 2019
Script to build the cartomix figure
View cartomix.R
library(cartography)
library(sp)
library(sf)
# Load data
data(nuts2006)
# Save image
sizes <- getFigDim(x = nuts0.spdf, width = 700, mar = c(0,0,0,0), res = 100)
png('./img/map8.png', width = sizes[1], height = sizes[2], res = 100)
@rCarto
rCarto / panamapapers.R
Last active Apr 4, 2016
Map of Panama Papers reporters
View panamapapers.R
# load library
library(cartography)
# load data
load(url("http://wukan.ums-riate.fr/panamapapers/panamapapers.RData"))
# get the figures dimensions
fd <- getFigDim(spdf = grat, width = 800,
res = 120, mar = c(0,0,1.2,0))
You can’t perform that action at this time.