Skip to content

Instantly share code, notes, and snippets.

View uribo's full-sized avatar
🍉
fine

Shinya Uryu uribo

🍉
fine
View GitHub Profile
@uribo
uribo / jma_normal_phenology.R
Created March 31, 2021 14:47
生物季節観測 さくらの開花日・満開日の期間
####################################
# 月*100+日
# 9月5日 --> 905
####################################
library(readr)
library(dplyr)
library(ggplot2)
library(ggalt)
d <-
read_csv("~/Downloads/normal_phenology/nml_phenology.csv",
@uribo
uribo / electric_usage_calendar.R
Created March 25, 2021 13:36
電力使用率をmoon chartsで表現する🌖⚡️
library(dplyr)
library(readr)
library(ggplot2)
library(gggibbous)
library(ggtext)
d <-
read_csv("https://www.tepco.co.jp/forecast/html/images/juyo-result-j.csv",
skip = 2,
locale = locale(encoding = "cp932"))
@uribo
uribo / zipangu210201.R
Last active February 2, 2021 00:26
zipangu v0.2.2
####################################
# zipangu v0.2.2
####################################
library(zipangu)
library(ggplot2)
library(patchwork)
theme_set(theme_bw(base_family = suryulib::jpfont(), base_size = 6))
# ベクトル化 -------------------------------------------------------------------
convert_jdate(c("令和3年2月1日", "令和元年5月1日", "平31年4月1日"))
@uribo
uribo / jma_record_temp.R
Last active August 25, 2020 13:03
気象庁 観測史上の記録
####################################
# 気象庁 観測史上の記録
####################################
library(tidyverse)
library(jmastats) # remotes::install_gitlab("uribo/jmastats")
library(ggalt)
library(sf)
library(patchwork)
tgt_st_block_no <- c("47418", "47407", "47412", "47575", "47582", "47590", "47615", "47662",
library(dplyr)
library(jmastats)
library(ggplot2)
source("https://raw.githubusercontent.com/uribo/japan-heatstroke/master/R/read_moe_wbgt.R")
wbgt_list1 <-
c(l1_lv5 = "#ff2800",
l1_lv4 = "#ff9600",
l1_lv3 = "#faf500",
l1_lv2 = "#a0d2ff",
@uribo
uribo / Transport_flowmap.R
Created July 17, 2020 09:52
Transport census flowmap
###################################
# 大都市交通センサス
# 第12回 首都圏 https://www.mlit.go.jp/sogoseisaku/transport/sosei_transport_tk_000007.html
# 線別駅間移動人員,
# 鉄道位置データ: 国土数値情報 鉄道時系列 https://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N05-v1_3.html
# 行政区画: 地球地図日本 https://www.gsi.go.jp/kankyochiri/globalmap.html
# 加工・編集者: 瓜生真也 (Shinya Uryu)
#
# mapboxよりアクセストークンを取得してください
###################################
@uribo
uribo / image_facet_mapping.R
Created March 5, 2020 01:21
imagerで異なる画像を読み込んでggplot2::facet_wrap()で表示する
library(imager)
library(ggplot2)
image_to_rgbdf <- function(file) {
imager::load.image(file) %>%
as.data.frame(wide = "c") %>%
dplyr::mutate(rgb_val = rgb(c.1, c.2, c.3))
}
df_plot <-
@uribo
uribo / dl_stat_data_mesharea.R
Last active January 20, 2020 01:22
tidyestat series
dl_stat_data_mesharea <- function(tbl_code, meshcode, exdir = ".", dest = TRUE) {
x <-
glue::glue("https://www.e-stat.go.jp/gis/statmap-search/data?statsId={tbl_code}&code={meshcode}&downloadType=2")
destfile <-
glue::glue(
"{exdir}/tbl{tbl_code}H{meshcode}.zip")
utils::download.file(url = x,
destfile = destfile)
if (dest == TRUE)
utils::unzip(
@uribo
uribo / read_ks_pop
Created November 2, 2019 01:49
tidy estat
read_ks_pop <- function(path, .tidy = TRUE) {
d <-
vroom::vroom(path,
locale = vroom::locale(encoding = "cp932"),
skip = 1,
col_types = paste0(c("cii"),
paste(rep("d", 42), collapse = ""), collapse = ""))
fix_names <-
stringi::stri_trans_nfkc(names(d)) %>%
stringr::str_trim() %>%
library(fgdr)
library(purrr)
library(sf)
library(h3forr)
library(ggplot2)
sf_hex <-
geo_to_h3(c(36.0670602, 140.0781036), res = 7) %>%
h3_to_geo_boundary() %>%
geo_boundary_to_sf()