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 mtq.R
library(raster)
library(cartography)
library(sf)
library(SpatialPosition)
mtq <- st_read(system.file("shape/martinique.shp", package="cartography"))
# use WGS84 proj
mtq_latlon <- st_transform(mtq, 4326)
# this call throw an error but seems to work...
getData('SRTM', lon=-61, lat=14)
View Paris.R
library(sf)
library(spatstat)
library(sp)
library(maptools)
library(raster)
library(cartography)
library(SpatialPosition)
## import dataset
feat <- sf::st_read("https://gist.githubusercontent.com/rCarto/747164575e3f216a123c3092d0ce9162/raw/f12390464f255b5f9760c577ab6bf5456cf61a40/iris75.geojson")
View iris75.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View cartogrammes.R
# load libraries
library(sf)
library(cartography)
library(cartogram)
## Import
# get the path to the shapefile embedded in sf package
shapepath <- system.file("shape/nc.shp",
package="sf")
# import the shapefile
View Penciling.R
## Figure 1
#download the dev version of cartography
devtools::install_github("riatelab/cartography")
library(sf)
library(cartography)
mtq <- st_read(system.file("shape/martinique.shp", package="cartography"))
mt1 <- mtq[3,]
mt2 <- getPencilLayer(mt1, size = 1000, lefthanded = T, buffer = 2000)
png(filename = "fig1.png", width = 474, height = 132, res = 100)
par(mfrow=c(1,3), mar = c(0,0,0,0))
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
You can’t perform that action at this time.