shapefile 编码错误问题解决

简介:

linux下运行,因为大部分shapefile 文件,在使用时都没有指定字符集,所以qgis只能从环境变量中获取设置环境变量中获取SHAPE_ENCODING。

目前唯一的解决办法就是设置环境变量

$ SHAPE_ENCODING=UTF-8
$ export SHAPE_ENCODING
$ qgis

I insist that this is a QGIS issue.

GDAL 1.9.0 (and newer) is trying to interpret the encoding setting from the shape file itself. When creating a new shape file “ENCODING” should be passed as an attribute, which, obviously, is not done.

Calling qgis from terminal allows two track down an warning messages. Saving non-Latin characters in a shape files generates following warning message: “Warning 1: One or several characters couldn't be converted correctly from UTF-8 to ISO-8859-1.
This warning will not be emitted anymore”.

On the other hand, most of the shape files used by users are without character encoding byte. So QGIS has to operate with environmental variable “SHAPE_ENCODING”. At present the only solution is to use the same character coding for the given QGIS session, e.g.:

SHAPE_ENCODING=UTF-8 export SHAPE_ENCODING qgis

The example above allows to create and edit shape files with UTF-8 as a character encoding (example for Linux users, Windows users must use “SET SHAPE_ENCODING=UTF-8”).

------------------------------------------------
Excerpt from

http://trac.osgeo.org/gdal/wiki/ConfigOptions

In C/C++ configuration switches can be set programmatically like this:

#include "cpl_conv.h" 
...
CPLSetConfigOption( "GDAL_CACHEMAX", "64" );

Normally a configuration option applies to all threads active in a program, but they can be limited to only the current thread this way:

CPLSetThreadLocalConfigOption( "GDAL_CACHEMAX", "64" );

 由 zirneklitis - 更新于 一年以上 之前

The Linux example above should be as follows:

$ SHAPE_ENCODING=UTF-8
$ export SHAPE_ENCODING
$ qgis

本文转自博客园知识天地的博客,原文链接:shapefile 编码错误问题解决,如需转载请自行联系原博主。


相关文章
|
5月前
|
定位技术 Windows
ArcGIS中ArcMap图层属性表的中文字段乱码的解决方法
ArcGIS中ArcMap图层属性表的中文字段乱码的解决方法
108 1
|
10月前
mapshaper命令:geojson转shp中文乱码的解决方案
mapshaper命令:geojson转shp中文乱码的解决方案
225 0
|
10月前
|
定位技术
ArcGIS:如何对Shapefile文件进行符号系统修改、标注、合并、分割、拓扑编辑等?
ArcGIS:如何对Shapefile文件进行符号系统修改、标注、合并、分割、拓扑编辑等?
261 0
|
8月前
|
C++
FreeCAD 导出STL格式文件格式
FreeCAD 导出STL格式文件格式
108 0
|
9月前
|
算法 Linux Python
SGAT丨基于R语言tidyverse的vcf转txt文件算法,SNP位点判断与自动校正,染色体格式替换
SGAT丨基于R语言tidyverse的vcf转txt文件算法,SNP位点判断与自动校正,染色体格式替换
|
12月前
|
Windows
ArcMap属性表汉字乱码的一种解决方法
本文介绍ArcMap软件打开图层的属性表后,出现字段中汉字乱码情况的解决方法~
248 1
ArcMap属性表汉字乱码的一种解决方法
AVI格式视频文件编码格式缺少编码解释器且该项目的编码格式不受支持(0xc00d5212错误)
AVI格式视频文件编码格式缺少编码解释器且该项目的编码格式不受支持(0xc00d5212错误)
1804 0
AVI格式视频文件编码格式缺少编码解释器且该项目的编码格式不受支持(0xc00d5212错误)
|
内存技术
【音频处理】WAV 文件格式分析 ( 逐个字节解析文件头 | 相关字段的计算公式 )(一)
【音频处理】WAV 文件格式分析 ( 逐个字节解析文件头 | 相关字段的计算公式 )(一)
315 0
【音频处理】WAV 文件格式分析 ( 逐个字节解析文件头 | 相关字段的计算公式 )(一)
|
内存技术
【音频处理】WAV 文件格式分析 ( 逐个字节解析文件头 | 相关字段的计算公式 )(三)
【音频处理】WAV 文件格式分析 ( 逐个字节解析文件头 | 相关字段的计算公式 )(三)
155 0
【音频处理】WAV 文件格式分析 ( 逐个字节解析文件头 | 相关字段的计算公式 )(三)