Skip to content

Instantly share code, notes, and snippets.

View LuisSevillano's full-sized avatar

Luis Sevillano LuisSevillano

View GitHub Profile
@LuisSevillano
LuisSevillano / get_leaflet_layers_polygons.js
Created January 19, 2024 10:54
Gell all polygons from a rendered Leaflet map
// chrome snippet
var layersMarkers = [];
var layersPolygons = [];
var layers = []
var geojson = {
"type": "FeatureCollection",
"features": []
}
var output = {
"type": "FeatureCollection",
@LuisSevillano
LuisSevillano / index.html
Last active November 9, 2023 14:23
Population around the biggest cities of Spain
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
html {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
@LuisSevillano
LuisSevillano / scale.js
Created January 4, 2021 19:06
Invert d3 scaleBand
// https://github.com/d3/d3-scale/blob/11777dac7d4b0b3e229d658aee3257ea67bd5ffa/src/band.js#L32
x.invert = function(_) {
const scale = this;
const domain = scale.domain;
const paddingOuter = scale.paddingOuter();
const paddingInner = scale.paddingInner();
const step = scale.step();
const range = scale.range();
var domainIndex,
@LuisSevillano
LuisSevillano / node.md
Last active October 30, 2019 15:24
Regex to replace commas to points in gedit

How to use a regex to replace commas with points using gedit: Having a csv like following:

c,m,p2019,p2016,p2015,p2011
w,x,"75.74","77.50","74.98","78.14"
g,f,"76.80","71.99","71.97","77.75"
i,b,"69.41","64.28","62.95","69.20"
b,h,"80.00","77.41","74.58","80.13"
@LuisSevillano
LuisSevillano / script.R
Created September 30, 2019 08:26
Extract data from ggplot plot
plot <- ggplot(data = pf, aes(x = age, y = df)) +
geom_point(alpha = 1/100,
position = position_jitter(h = 0),
color = "darkred")
ggplot(data = layer_data(plot, 1), aes(x = x, y = y)) +
geom_point(alpha = 1/20)
@LuisSevillano
LuisSevillano / .block
Last active October 19, 2019 11:15
New composite border in es-atlas
border:none
height:696
license:MIT
@LuisSevillano
LuisSevillano / autonomous_regions.json
Created August 14, 2019 18:51
Preprojected TopoJSON
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@LuisSevillano
LuisSevillano / .block
Last active September 13, 2019 09:24
d3-composite-projections test
border:none
height:700
@LuisSevillano
LuisSevillano / combineHeaders.R
Last active August 8, 2019 17:57
A R function to deal with datasets with a double header
library(tidyverse)
library(ggplot2)
library(janitor)
library(readxl)
filePath <- "data/4247.xlsx"
csv <- read_xlsx(filePath, skip = 6)
# This function fills empty cells with previous values to the right and then combine them with the row above
@LuisSevillano
LuisSevillano / .block
Last active May 23, 2019 19:20
Rivers of Spain
border: none
height: 650