使用readOGR时对德语变音符号的编码 [英] Encoding of German umlauts when using readOGR

查看:61
本文介绍了使用readOGR时对德语变音符号的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 rgdal 包提供的 readOGR 函数读取OGR矢量地图,但是我在使用德国变音符号方面遇到了一些麻烦.我提供了数据的外观的一个小例子,像ö这样的变音符号已替换为 \ 303 \ 266 .

I'm trying to read an OGR vector map using the readOGR function provided by the rgdal package, but I'm having a little trouble with the German umlauts. I've provided a little example of what the data looks like, umlauts like ö are replaced with \303\266.

map <-readOGR("/path/to/data.gdb", layer = "layer")
map@data$name
# [1] L\303\266rrach
# [2] Karlsruhe
# [3] B\303\266blingen
# [4] ...

我尝试在 readOGR 函数中指定一种编码( readOGR(dsn ="/path/to/data.gdb",layer ="layer",encoding ="UTF-8" readOGR(dsn ="/path/to/data.gdb,layer =" layer,编码=" LATIN-1"),但看起来像它完全忽略了编码参数,因为我尝试的每种编码都得到相同的结果,有人知道我如何获得 readOGR 函数或R以显示正确的德语变音符号吗?

I've tried to specify an encoding in the readOGR function (readOGR(dsn = "/path/to/data.gdb", layer = "layer", encoding = "UTF-8" or readOGR(dsn = "/path/to/data.gdb", layer = "layer", encoding = "LATIN-1"), but it looks like it is ignoring the encoding parameter completely, since I'm getting the same result for each encoding I've tried. Does anybody know how I can get the readOGR function or R to display the correct German umlauts?

推荐答案

我不太确定 encoding ="UTF-8/LATIN-1/..."会做什么.我曾希望您会选择一种且只有一种编码方案.在我的机器上,我确实看到了该八进制字符到o-umlaut的翻译:

I'm not quite sure what encoding = "UTF-8/LATIN-1/..." might do. I would have expected that you would choose one and only one encoding scheme. On my machine I do see the translation of that octal character to the o-umlaut:

> 'B\303\266blingen'
[1] "Böblingen"
> 'L\303\266rrach'
[1] "Lörrach"

要查看R字符的各种约定,请输入:

To see the various conventions for R characters, type:

?Quotes

除编码外,还需要在使用的字体中包含字符.控制台显示中使用的字体似乎没有用于o-umlaut的正确映射.我的默认字体是Courier.您还应该检查区域设置.?Sys.getlocale

Besides encodings, there is also the need to have characters in the font being used. The font used in your console display doesn't seem to have the proper mappings for o-umlaut. My default font is Courier. You should also check your locale settings. ?Sys.getlocale

这篇关于使用readOGR时对德语变音符号的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆