Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically convert character encoding #6

Closed
yutannihilation opened this issue Aug 24, 2017 · 0 comments
Closed

Automatically convert character encoding #6

yutannihilation opened this issue Aug 24, 2017 · 0 comments

Comments

@yutannihilation
Copy link
Owner

Some are encoded in CP932 whereas sf always marks it as UTF-8:

getKSJData('http://nlftp.mlit.go.jp/ksj/gml/data/P12/P12-14/P12-14_05_GML.zip')
#> (...snip...)
#> $`P12a-14_05`
#> Simple feature collection with 621 features and 7 fields
#> geometry type:  MULTIPOINT
#> dimension:      XY
#> bbox:           xmin: 139.7046 ymin: 38.95984 xmax: 140.8945 ymax: 40.46308
#> epsg (SRID):    NA
#> proj4string:    +proj=longlat +ellps=GRS80 +no_defs
#> # A tibble: 621 x 8
#>    都道府県コード                                                                                     行政コード
#>             <int>                                                                                          <chr>
#>  1          10001                                   "\u008fH\u0093c\u008a<U+0193>\u0095\u0082<U+0702>\u0082\xe8"
#>  2          10002                          "\u008fH\u0093c\u008es\u0091\xe5\u0090X\u008eR\u008c\xf6\u0089\u0080"
#>  3          10003                       "\u008fH\u0093c\u008es\u0089\u0516\u060a<U+03CC>\xf5\u0094_\u0089\u0080"
#>  4          10004   "\u008fH\u0093c\u008es\u0095l\u0093c\u0090X\u0097ё\u008d\u008d\u0087\u008c\xf6\u0089\u0080"
#>  5          10005                                 "\u008e<U+00A9>\u0091R\u0089<U+020A>w\u008aw\u008fK\u008a\xd9"
#>  6          10006                        "\u008fH\u0093c\u008es\u0095<U+00B6>\u0089<U+00BB>\u0089\xef\u008a\xd9"
#>  7          10007                   "\u008fH\u0093c\u008c<U+00A7>\u008e\u0099\u0093<U+00B6>\u0089\xef\u008a\xd9"
#>  8          10008  "\u008c\xfc\u0095l\u0089^\u0093<U+00AE>\u008c\xf6\u0089\u0080\u0096<U+C2C5>\u008dL\u008f\xea"
#>  9          10009 "\u008fH\u0093c\u008c<U+00A7>\u0097<U+00A7>\u0091\u008d\u008d\u0087\u0083v\u0081[\u0083\u008b"
#> 10          10010                              "\u008e\xed\u0091\xf2\u0083\u008a\u0083\u0093\u0083S\u0089\u0080"
#> # ... with 611 more rows, and 6 more variables: 資源名称 <chr>, 資源名称.1 <chr>, 種別名称 <chr>, P12_006 <chr>,
#> #   P12_007 <int>, geometry <S3: sfc_MULTIPOINT>

This can be easily converted into native encoding by iconv().

d <- getKSJData('http://nlftp.mlit.go.jp/ksj/gml/data/P12/P12-14/P12-14_05_GML.zip')
dplyr::mutate_if(d$`P12a-14_05`, is.character, iconv, from = "CP932")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant