Skip to content

yutannihilation/kokudosuuchi-metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kokudosuuchi-metadata

Structure

  • Rmd: R Markdownを置く
    • 01: 調査
    • 02: HTMLファイルをダウンロード
    • 03: HTMLファイルの調査
    • 04: HTMLファイルから列名とコードの対応、その説明を抜き出す(data/attrsに入る)
    • 05: 抜き出したデータの確認
    • 06: 抜き出したデータを整形してコードと列名の対応のデータを生成(data/colnames_*に入る)
    • 07: コードリストの情報を抜き出す(data/codelistに入る)
    • 08: 抜き出してきたデータを統合する
  • data-raw: 生データを置くところ
    • zip: テスト用のデータ
    • datalist: データについての説明のHTML
    • codelist: コードリスト型の列のコードとラベルの対応のHTMLやExcel
  • data: 展開したデータを置くところ
    • attrs: とりあえず抜き出してきた状態のデータ
    • colnames_*: 列名とコードの対応
    • codelist: コードリストのコードトラベルの対応
  • scripts: 参考実装(いずれ kokudosuuchi に移植する)

難しい点

コードと列名の対応

コードと列名の対応は主に、HTMLとExcelの2箇所にある。

  • HTML: 列の説明や型、コードリストへのリンクなど詳細情報があるが、列のIDが書かれていない場合がある(ので、列名でマッチさせるのでなく順序でマッチさせる必要がある)。
  • Excel: 列のIDと名前の対応は揃っているが、型やコードリストの記載がない。

この2つを紐付ければ列の型もIDも揃ってよさそうに見えるが、たぶんそれはそれで列名ではjoinできないやつがあったりして苦労が増えそう。 また、どちらも実データと一致している保証はないので、結局確認しながら手で修正していくことになる。

Coverages

test_data <- fs::dir_ls(here::here("data-raw", "zip"))
cache_dir <- here::here("cache")

dir.create(cache_dir, showWarnings = FALSE)

source(here::here("scripts", "read_ksj_data.R"))
translate_columns_safe <- purrr::safely(translate_columns)
read_zip_with_cache_safe <- purrr::safely(read_zip_with_cache)

result <- purrr::map(test_data, ~ {
  suppressWarnings(l <- read_zip_with_cache_safe(.x, cache_dir = cache_dir))
  if (!is.null(l$error)) {
    return(l)
  }
  translate_columns_safe(l$result)
})

errors <- purrr::map_chr(result, ~ {
  if (is.null(.$error)) {
    return(NA_character_)
  }
  
  as.character(.$error)
})

library(dplyr, warn.conflicts = FALSE)

tibble::enframe(errors) %>% 
  mutate(
    name = basename(names(errors))
  ) %>% 
  knitr::kable()
name value
1km_mesh_suikei_2018_shape_06.zip Error: Not implemented
500m_mesh_suikei_2018_shape_23.zip Error: Not implemented
A03-03_SYUTO-tky_GML.zip NA
A09-18_22_GML.zip NA
A10-15_13_GML.zip NA
A11-15_42_GML.zip NA
A12-15_08_GML.zip NA
A13-15_21_GML.zip NA
A15-15_14_GML.zip NA
A16-15_04_GML.zip NA
A17-17_01_GML.zip NA
A18-16_12_GML.zip NA
A18-16_24_GML.zip NA
A18s-a-10_GML.zip NA
A19-001001_01_GML.zip NA
A19s-a-10_28_GML.zip NA
A20-540621_46_GML.zip NA
A20s-10_46_GML.zip NA
A21-070402_13_GML.zip NA
A21s-10_13_GML.zip NA
A22-16_17_GML.zip NA
A22-16_19_GML.zip NA
A22-m-14_34_GML.zip NA
A22s-10_10_GML.zip NA
A23-16_31_GML.zip NA
A24-16_03_GML.zip NA
A25-16_04_GML.zip NA
A26-10_40_GML.zip NA
A27-16_08_GML.zip NA
A28-11_GML.zip NA
A29-19_07_GML.zip NA
A30a5-11_5338-jgd_GML.zip NA
A30b-11_GML.zip NA
A31-19_86_SHP.zip NA
A32-16_15_GML.zip NA
A33-19_05_GML.zip NA
A34-180316_GML.zip NA
A35a-14_02_GML.zip NA
A35b-14_26_GML.zip NA
A35c-14_01_GML.zip NA
A37-15_45_GML.zip NA
A38-14_14_GML.zip NA
A39-15_GML.zip NA
A40-16_39_GML.zip NA
A42-18_GML.zip NA
A43-18_GML.zip NA
A44-18_GML.zip NA
A45-19_18_GML.zip NA
C02-14_GML.zip NA
C09-06_GML.zip Error: Failed to translate these codes in 都道府県コード: 50
C23-06_32_GML.zip NA
C28-19_GML.zip NA
G02-12_4229-jgd_GML.zip NA
G04-a-11_3927-jgd_GML.zip NA
G04-c-11_6742-jgd_GML.zip NA
G04-d-11_4530-jgd_GML.zip NA
G08-15_44_GML.zip NA
L01-18_01_GML.zip NA
L01-20_30_GML.zip NA
L01-95_01_GML.zip Error: The number of columns doesn’t match with the expectation
L02-20_33_GML.zip NA
L03-a-16_3622-jgd_GML.zip Error: Not translated
L03-b-16_3623-tky_GML.zip Error: Not translated
L03-b-c-16_5440_GML.zip NA
L03-b-u-16_3927-jgd_GML.zip Error: Not translated
L05-2-09_33_GML.zip NA
N02-19_GML.zip NA
N03-20200101_04_GML.zip NA
N04-02_4934-jgd_GML.zip NA
N04-03_4934-jgd_GML.zip NA
N04-04_4934-jgd_GML.zip NA
N04-10_4934-jgd_GML.zip NA
N04-78_4934-tky_GML.zip NA
N05-19_GML.zip NA
N06-19_GML.zip NA
N07-11_41_GML.zip NA
N08-19_GML.zip NA
N09-12_GML.zip NA
N10-15_40_GML.zip NA
N11-13_39.zip NA
P02-06_38_GML.zip NA
P03-13.zip Error: Failed to translate these codes in 種別: -2
P04-14_37_GML.zip NA
P05-10_36_GML.zip NA
P07-15_35_GML.zip NA
P09-10_5032-jgd_GML.zip NA
P11-10_36_GML.zip NA
P12-14_35_GML.zip Error: Failed to translate these codes in 観光資源分類コード: -1
P13-11_34_GML.zip NA
P14-15_32_GML.zip NA
P15-12_31_GML.zip NA
P16-12_32_GML.zip NA
P17-12_29_GML.zip NA
P18-12_27_GML.zip NA
P19-12_30_GML.zip NA
P20-12_28_GML.zip NA
P21-12_15_GML.zip NA
P21-12_27_GML.zip NA
P22-12_14_GML.zip NA
P23-12_17_GML.zip NA
P24-12_GML.zip NA
P26-13_34.zip NA
P27-13_38.zip NA
P28-13_41.zip NA
P29-13_47.zip NA
P30-13_47.zip NA
P31-13_46.zip NA
P32-14_45_GML.zip NA
P33-14_44_GML.zip NA
P34-14_42_GML.zip NA
P35-18_GML.zip NA
S05-a-10_KINKI_GML.zip NA
S05-a-13_CHUBU-g.zip NA
S05-b-10_KINKI_GML.zip NA
S05-b-13_CHUBU-g.zip NA
S05-c-10_SYUTO_GML.zip NA
S05-c-12_KINKI_GML.zip NA
S05-d-16_GML.zip NA
S10a-16_GML.zip NA
S10b-14_GML.zip NA
S12-19_GML.zip NA
W01-14_GML.zip Error: Failed to translate these codes in 形式: -
W05-07_45_GML.zip Error: Failed to translate these codes in 水系域: 450000
W07-09_6841-jgd_GML.zip NA
W09-05_GML.zip NA
m1000-17_39_GML.zip Error: Not implemented
m500-17_14_GML.zip Error: Not implemented

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages