r - 如何将韩文脚本 shapefile 读入 R/sf
问题描述
shapefiles 中的韩文(韩文)脚本在读入 R 的过程中被破坏。
从此网站下载首尔、仁川、京畿道地区 shapefile (韩文)。我附上这些文件,因为它们在韩国以外无法访问。
我在英文版的 Windows 10 上使用 RStudio。以防万一,将 RStudio 默认文本编码设置为“UTF-8”并将语言环境设置为韩语:
Sys.setlocale(category="LC_ALL", locale = "Korean")
使用包将 shapefile 读入 R sf
:
library(sf)
#Read, name and combine regions
sca_nsdi <- rbind(cbind(st_read("LARD_ADM_SECT_SGG_11.shp"), Name="Seoul"),
cbind(st_read("LARD_ADM_SECT_SGG_28.shp"), Name="Incheon"),
cbind(st_read("LARD_ADM_SECT_SGG_41.shp"), Name="Gyeonggi-do"))
#View result
View(sca_nsdi)
列中的韩文SGG_NM
是不可读的,以及通过控制台:
sca_nsdi$SGG_NM[1]
[1] ������
解决方案
我终于想通了:
Sys.setlocale(category="LC_ALL", locale = "Korean")
sca_nsdi <- rbind(cbind(st_read("LARD_ADM_SECT_SGG_11.shp", options="ENCODING=EUC-KR"), Name="Seoul"),
cbind(st_read("LARD_ADM_SECT_SGG_28.shp", options="ENCODING=EUC-KR"), Name="Incheon"),
cbind(st_read("LARD_ADM_SECT_SGG_41.shp", options="ENCODING=EUC-KR"), Name="Gyeonggi-do"))
推荐阅读
- javascript - 我试图在php中将相同的值从页面移动到另一个
- json - 如何在里面创建带有 json 的文件?
- html - 如何更改使用两根手指移动地图消息的位置
- powershell - --data-raw in powershell InvokeWebRequest
- docker - 从运行在 kubernetes 集群中的 docker 容器生成堆转储
- python - 在 pandas read_sql 中指定数据类型的最佳方法是什么?
- javascript - Vue:动态“v-slot = { value }”导致div被隐藏
- c++ - 为什么这个 C 函数计算 sqrt 不能用于小数?
- swift - 不可见时向上移动文本字段
- javascript - JQuery 选择器的 Angular 等价物