加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

【R】readOGR读取shp,中文乱码,解决办法

(2017-09-22 17:09:09)
标签:

r

分类: 技术
网上有的说需要如下设置:
setCPLConfigOption("SHAPE_ENCODING","")
我这里没有效果

我用的版本:
rgdal: version: 1.2-11, (SVN revision 676)

解决方案:
poi <- readOGR(dsn, layer, use_iconv = TRUE, encoding = "UTF-8")

只设置encoding是没有用的,因为:
The encoding-parameter is ignored, if iconv is not set to TRUE.

官方文档说明    encoding:

default NULL, if set to a character string, and the driver is “ESRI Shapefile”, and use_iconv is FALSE, it is passed to the CPL Option “SHAPE_ENCODING” immediately before reading the DBF of a shapefile. If use_iconv is TRUE, and encoding is not NULL, it will be used to convert input strings from the given value to the native encoding for the system/platform.

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有