Skip to content

Instantly share code, notes, and snippets.

@fanghuiz
fanghuiz / heatmap_daily_temp_england.R
Created September 4, 2019 02:08
Create heatmap to visualize the daily temperature in England over 100 years
library(tidyverse)
library(lubridate)
# Dataset URL
url_eng_daily_max <- "https://www.metoffice.gov.uk/hadobs/hadcet/cetmaxdly1878on_urbadj4.dat"
# Read in data from URL
eng_daily_max <- data.table::fread(
url_eng_daily_max,
# Encode -999 as NA
@fanghuiz
fanghuiz / movie_color_bar.py
Last active October 6, 2024 16:30
Script to generate a color timeline based on video input (movie etc.) Modified from https://github.com/lint/avg-color-bar
from PIL import Image, ImageEnhance
import os
import subprocess
import sys
# Requires ffmpeg https://www.ffmpeg.org/ffmpeg.html
# Run script as
# python movie_color_bar.py input_video output_frame_folder output_image
@fanghuiz
fanghuiz / map_active_fire.R
Created September 23, 2019 22:43
Animated map showing daily active fires in Indonesia this September
# Set up
library(ggplot2)
library(dplyr)
library(ggmap)
library(maps)
library(gganimate)
# Request raw data from https://firms.modaps.eosdis.nasa.gov/active_fire/#firms-txt
# Data used for this map
url <- "https://raw.githubusercontent.com/fanghuiz/random_viz/master/data/fire_IND_201909.csv"
@fanghuiz
fanghuiz / soc
Created November 5, 2019 18:08 — forked from nkthiebaut/soc
Codes to names mapping for the O*NET-SOC job titles classification (https://www.onetcenter.org/taxonomy.html)
SOC_MAJOR_GROUPS = {
"11": "Management Occupations",
"13": "Business and Financial Operations Occupations",
"15": "Computer and Mathematical Occupations",
"17": "Architecture and Engineering Occupations",
"19": "Life, Physical, and Social Science Occupations",
"21": "Community and Social Service Occupations",
"23": "Legal Occupations",
"25": "Education, Training, and Library Occupations",
"27": "Arts, Design, Entertainment, Sports, and Media Occupations",