Skip to content

Instantly share code, notes, and snippets.

Last active September 14, 2023 16:36
Star You must be signed in to star a gist
What would you like to do?
Submarine Cable Map Dataviz
#Data source:
cables = geojson_sf("cable-geo.json")
cablescene = list()
counter = 1
for(i in 1:length(cables$geometry)) {
for(j in 1:length(cables$geometry[[i]])) {
temp = cables$geometry[[i]][[j]]
cableval = data.frame(x=sinpi(temp[,1]/180)*cospi(temp[,2]/180),
#Don't lower start of line at the 180/0 longitude border
if(abs(temp[1,1] - 180) > 0.001 && abs(temp[1,1] + 180) > 0.001) {
cableval[1,] = cableval[1,] * 1/1.02
nr = nrow(temp)
#Don't lower end of line at the 180/0 longitude border
if(abs(temp[nr,1] - 180) > 0.001 && abs(temp[nr,1] + 180) > 0.001) {
nr = nrow(cableval)
cableval[nr,] = cableval[nr,] * 1/1.02
cablescene[[counter]] = path(cableval, width = 0.005,material=diffuse(color=cables$color[i]))
counter = counter + 1
fullcablescene =,cablescene)
for(i in seq(1,720,by=1)) {
group_objects(fullcablescene,scale=c(1,1,1)*1.02) %>%
add_object(sphere(radius=0.99,material=diffuse(image_texture = "2k_earth_daymap.jpg"),angle=c(0,-90,0))) %>%
group_objects(angle=c(0,-i/2,0)) %>%
add_object(sphere(y=5,z=5,x=5,material=light(intensity = 80,color="lightblue"))) %>%
add_object(sphere(y=5,z=5,x=-5,material=light(intensity = 10,color="orange"))) %>%
add_object(sphere(y=-10,material=light(intensity = 3,color="white"))) %>%
render_scene(samples=64,width=1200,height=1200,fov=0,aperture=0, ortho_dimensions = c(2.3,2.3),
sample_method = "sobol_blue",filename=sprintf("smallcables%d.png",i))
Copy link

YoViajo commented Sep 30, 2021

Como se puede ejecutar este archivo?

  • Descarga los archivos a los que hace referencia el código R (1 archivo GeoJSON, 1 archivo JPG) usando los enlaces mencionados líneas arriba (en los comentarios)
  • En el código R, ajusta la referencia de ruta de los archivos descargados (según tu definición)
  • Ejecuta el código R en tu ambiente favorito (e.g, R-Studio). Prepárate para esperar. En mi caso tomó 40 horas en completar.
  • La salida es grupo de imágenes PNG que visualizadas juntas pueden animarse como un video. Yo utilicé ffmpeg para hacer esa combinación.

Copy link

The SFU link for the JPG doesn't work, here's the wikimedia source file.

Copy link


I was wondering if anyone still had access to a repo of the Telegeography submarine cable map. They no longer maintain their public github as of 2 weeks ago, and I wanted to look at their source code. Thank you!

Copy link

I was looking for it as well, I think you get it from the attachments here,
Good Luck!

Copy link

bunam commented Mar 9, 2023

I have consolidated and modified a little there :

Copy link

mb720 commented Sep 8, 2023

Some pointers for beginners to R:

  • You'll need three R packages: "geojsonsf", "sf", and "rayrender"
  • "sf" expects some libraries to be installed on your system, see its readme on how to do this, for example for Linux
  • You'll need a Fortran compiler. If you're on Arch Linux: pacman -S gcc-fortran
  • After installing R and opening its command line, install the packages with install.packages(c("geojsonsf", "sf", "rayrender"))
  • Then run the script with source("submarine_cable_map.R")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment