Skip to content

Instantly share code, notes, and snippets.

@jscarto
jscarto / vintage_viridis.js
Created September 8, 2021 18:43
Color palette based on an old map that has many similarities to Viridis: https://twitter.com/infowetrust/status/1435641914649288707
vintageViridis = ['#191718', '#191819', '#1a191b', '#1a191c', '#1a1a1d', '#1b1b1f', '#1b1b20', '#1c1b20', '#1c1c22', '#1d1d24', '#1d1d24', '#1d1e26', '#1d2028', '#1d2028', '#1e212a', '#1e222c', '#1e222c', '#1f232e', '#1f2430', '#1f2430', '#1f2532', '#202633', '#202635', '#202735', '#202737', '#212939', '#212939', '#21293b', '#212a3c', '#212c3d', '#212d3e', '#212d3f', '#222e3f', '#222e40', '#223041', '#223042', '#223143', '#223244', '#223344', '#223445', '#223446', '#233547', '#233648', '#233648', '#233849', '#23384a', '#233a4b', '#233b4c', '#233c4d', '#233c4d', '#233c4e', '#233e4f', '#233f50', '#234051', '#234052', '#234253', '#234254', '#234254', '#234355', '#234556', '#234557', '#234658', '#234759', '#23485a', '#23485a', '#23495b', '#234b5c', '#234c5d', '#234d5e', '#224d5f', '#224e60', '#224f61', '#225061', '#225162', '#225163', '#225264', '#225465', '#225566', '#215667', '#215668', '#215768', '#215869', '#21596a', '#215a6b', '#205b6c', '#205c6d', '#205d6e', '#205e6f', '#1f5f70', '#1f5f71', '#1f6072', '#1f6
@jscarto
jscarto / gibbs_export.sh
Last active January 18, 2022 16:55
Export a single image from GIBBS tile server. // UNTESTED MAY NOT WORK
outformat=JPEG
category=best
layer=MODIS_Terra_CorrectedReflectance_TrueColor
caldate=2020-09-09
tileset=250m
ext=jpg
tilelevel=9
bands=3
tmp_image=output.jpg
@jscarto
jscarto / blue_fluorite.xml
Created September 23, 2020 14:45
Blue Fluorite Color Palette for QGIS
<!DOCTYPE qgis_style>
<qgis_style version="2">
<symbols/>
<colorramps>
<colorramp name="Blue Fluorite" type="gradient">
<prop v="41,27,50,255" k="color1"/>
<prop v="241,243,238,255" k="color2"/>
<prop v="1" k="discrete"/>
<prop v="gradient" k="rampType"/>
<prop v="0.00390625;42,27,52,255:0.0078125;43,27,52,255:0.0117188;45,28,54,255:0.015625;47,28,56,255:0.0195313;48,28,57,255:0.0234375;48,29,58,255:0.0273438;50,29,59,255:0.03125;51,29,61,255:0.0351563;53,29,63,255:0.0390625;53,30,64,255:0.0429688;55,30,65,255:0.046875;56,30,67,255:0.0507813;58,30,69,255:0.0546875;59,31,69,255:0.0585938;60,31,70,255:0.0625;62,31,72,255:0.0664063;63,31,74,255:0.0703125;64,31,76,255:0.0742188;66,32,77,255:0.078125;67,32,78,255:0.0820313;68,32,79,255:0.0859375;70,32,81,255:0.0898438;71,32,82,255:0.09375;72,32,84,255:0.0976563;74,32,86,255:0.101563;74,33,87,255:0.105469;76,33,88,255:0.109375;78,33,90,255:0.113281;79,33,91,255:0.117188;80,33,93,255:0.121094;82,33,94,255:0.125;83,33,96,255:0.12
@jscarto
jscarto / Blue Fluorite Palette
Last active September 24, 2020 06:03
Perceptually linear color palette based on a blue fluorite crystal (https://twitter.com/GeologyTime/status/1308406136283049984)
blue_fluorite = ['#291b32', '#2a1b34', '#2b1b34', '#2d1c36', '#2f1c38', '#301c39', '#301d3a', '#321d3b', '#331d3d', '#351d3f', '#351e40', '#371e41', '#381e43', '#3a1e45', '#3b1f45', '#3c1f46', '#3e1f48', '#3f1f4a', '#401f4c', '#42204d', '#43204e', '#44204f', '#462051', '#472052', '#482054', '#4a2056', '#4a2157', '#4c2158', '#4e215a', '#4f215b', '#50215d', '#52215e', '#532160', '#552162', '#552263', '#562264', '#582265', '#592267', '#5b2268', '#5c226b', '#5e226c', '#5f226e', '#60226f', '#622271', '#632272', '#642274', '#662276', '#672277', '#692278', '#6a227a', '#6c227b', '#6e227d', '#6e237e', '#6f247f', '#702480', '#712581', '#722681', '#732683', '#742783', '#752884', '#762985', '#772987', '#792a87', '#792b88', '#7a2c89', '#7b2c8a', '#7c2d8a', '#7d2d8c', '#7e2e8d', '#7f2f8d', '#80308e', '#813190', '#823191', '#833292', '#843292', '#863393', '#863494', '#873595', '#893596', '#8a3697', '#8b3798', '#8b3899', '#8c389a', '#8e399b', '#8e3a9c', '#8f3b9c', '#8f3d9d', '#8f3e9e', '#903f9e', '#90419e', '#90439f', '#9044
@jscarto
jscarto / read_gedi.py
Created January 24, 2020 18:08
Example: Reading GEDI Level 2A data in Python
import h5py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# read file
file = 'GEDI02_A_2019138044926_O02428_T03843_02_001_01.h5'
f = h5py.File(file, 'r')
# get some variables for BEAM0000 (change to other beam/vars as needed)
@jscarto
jscarto / gdal_loop.sh
Created April 2, 2019 20:04
An example using Bash and gdal to loop through existing tif files to create 16-bit scaled versions, with new filenames including "_stretched"
#!/bin/bash
for f in *. tif; do
gdal_translate -ot UInt16 -scale 0 8e-9 0 65536 -outsize 800 0 -r bilinear $f "${f%.*}_stretched.tif"
done
@jscarto
jscarto / arid_elevation.js
Created January 16, 2019 02:40
Arid elevation palette
['#999188','#9a9188','#9a9288','#9b9289','#9b9289','#9b938a','#9c938a','#9c948a','#9d948b','#9d948b','#9d958b','#9e968c','#9e968c','#9f968c','#9f978c','#a0978d','#a0978d','#a0988d','#a1998e','#a1998e','#a2998e','#a29a8f','#a29a8f','#a39b90','#a39b90','#a49c90','#a49b90','#a49c90','#a69d91','#a69c91','#a79d92','#a79e92','#a79e92','#a89e93','#a89e93','#a99f93','#a99f94','#aaa094','#aaa094','#aaa094','#aba295','#aba295','#aca296','#aca296','#aca396','#ada397','#ada497','#aea497','#aea598','#aea598','#afa599','#afa699','#b0a699','#b1a699','#b1a799','#b2a89a','#b2a89a','#b3a89b','#b3a99b','#b3a99c','#b4a99c','#b4aa9c','#b5aa9d','#b5aa9d','#b6ab9d','#b6ac9e','#b6ab9e','#b7ac9e','#b7ac9e','#b8ad9f','#b8ad9f','#b9ae9f','#b9afa0','#b9aea0','#baafa1','#bbafa1','#bbb0a1','#bcb1a2','#bcb0a2','#bdb1a3','#bdb2a3','#beb2a3','#beb2a4','#beb2a4','#bfb4a4','#bfb4a4','#bfb4a5','#c0b4a5','#c0b5a6','#c1b6a6','#c1b6a6','#c2b7a7','#c2b6a7','#c3b7a7','#c4b8a8','#c4b7a8','#c5b8a9','#c5b9a9','#c5b9aa','#c6b9aa','#c6b9aa','#c7bbab','#c
@jscarto
jscarto / arid_elevation.js
Created January 16, 2019 02:40
Arid elevation palette
['#999188','#9a9188','#9a9288','#9b9289','#9b9289','#9b938a','#9c938a','#9c948a','#9d948b','#9d948b','#9d958b','#9e968c','#9e968c','#9f968c','#9f978c','#a0978d','#a0978d','#a0988d','#a1998e','#a1998e','#a2998e','#a29a8f','#a29a8f','#a39b90','#a39b90','#a49c90','#a49b90','#a49c90','#a69d91','#a69c91','#a79d92','#a79e92','#a79e92','#a89e93','#a89e93','#a99f93','#a99f94','#aaa094','#aaa094','#aaa094','#aba295','#aba295','#aca296','#aca296','#aca396','#ada397','#ada497','#aea497','#aea598','#aea598','#afa599','#afa699','#b0a699','#b1a699','#b1a799','#b2a89a','#b2a89a','#b3a89b','#b3a99b','#b3a99c','#b4a99c','#b4aa9c','#b5aa9d','#b5aa9d','#b6ab9d','#b6ac9e','#b6ab9e','#b7ac9e','#b7ac9e','#b8ad9f','#b8ad9f','#b9ae9f','#b9afa0','#b9aea0','#baafa1','#bbafa1','#bbb0a1','#bcb1a2','#bcb0a2','#bdb1a3','#bdb2a3','#beb2a3','#beb2a4','#beb2a4','#bfb4a4','#bfb4a4','#bfb4a5','#c0b4a5','#c0b5a6','#c1b6a6','#c1b6a6','#c2b7a7','#c2b6a7','#c3b7a7','#c4b8a8','#c4b7a8','#c5b8a9','#c5b9a9','#c5b9aa','#c6b9aa','#c6b9aa','#c7bbab','#c
@jscarto
jscarto / carrots.py
Last active June 6, 2018 20:56
Carrots Palette
# Perceptually linear color palette based on an image of carrots
carrots = ['#372442','#4e1831','#4f1933','#501933','#511a34','#511b36','#521c37','#531c37','#531d39','#541e3a','#551f3a','#561f3c','#56203d','#57213e','#58223f','#582241','#592341','#5a2342','#5b2444','#5c2545','#5c2546','#5d2647','#5e2749','#5e2849','#5f284a','#60294c','#602a4c','#612b4e','#622b4f','#632c50','#642c50','#662c4f','#692c4f','#6a2c4f','#6e2b4e','#6f2b4e','#712b4d','#732b4d','#742b4d','#772b4c','#7a2a4b','#7c2a4b','#7c2a4b','#7e2a4a','#81294a','#832949','#842949','#872949','#892848','#8a2848','#8d2848','#8f2747','#912747','#932646','#952646','#972545','#982545','#9b2444','#9d2444','#9f2344','#a02343','#a32243','#a42142','#a62142','#a92042','#ab1f41','#ad1e41','#ae1d40','#b01c40','#b21b3f','#b31b3f','#b7193e','#b8183e','#b91a3f','#b91d40','#ba1f41','#bb2042','#bb2244','#bc2344','#bc2646','#bd2747','#bd2948','#be2a49','#bf2b49','#bf2e4b','#c0304c','#c1304b','#c2324b','#c3344a','#c3354a','#c43649','#c53749','#c53948','#c63a48','#c73c47
@jscarto
jscarto / fl_keys.py
Created May 17, 2018 14:38
Florida Keys Sunset Color Palette
# Perceptually linear palette derived from https://twitter.com/StuOstro/status/996951291032154112
florida_colors = ['#060910','#070a12','#080b14','#080d15','#090e17','#0a0f18','#0b101a','#0b111b','#0c121d','#0c131e','#0d1420','#0d1422','#0d1524','#0e1625','#0e1725','#0f1726','#101927','#101927','#111928','#131b29','#141b29','#141b2a','#151c2a','#161d2b','#171e2b','#181f2c','#191f2d','#1a202e','#1a212e','#1b222f','#1c222f','#1e2330','#1e2430','#1f2531','#202532','#212632','#212633','#222834','#232834','#242935','#252935','#262b36','#272c37','#282c38','#292d38','#292d38','#2a2f39','#2c303a','#2c303b','#2d303b','#2e313c','#2f323c','#30333d','#31343e','#31343e','#32353f','#333740','#353740','#36383f','#38383e','#3b393e','#3b3a3d','#3e3b3c','#403b3b','#403c3b','#423c3a','#453d39','#453e39','#473f38','#494037','#4a4036','#4c4036','#4e4235','#504234','#514333','#524433','#544431','#554531','#564530','#58472f','#5a472e','#5a482e','#5c492d','#5e4a2b','#604a2b','#604b2a','#624c29','#644d28','#654d27','#684d27','#684e2