在我們的組織中,我們處理不同文件格式的GIS內容。我需要將這些文件放入PostGIS數據庫,並使用ogr2ogr完成。問題是,數據庫是UTF8編碼的,文件可能有不同的編碼。ogr2ogr和Postgis/PostgreSQL數據庫的編碼問題
我發現瞭如何通過向org2ogr添加選項參數來指定編碼的說明,但是顯然它沒有效果。
ogr2ogr -f PostgreSQL PG:"host=localhost user=username dbname=dbname \
password=password options='-c client_encoding=latin1'" sourcefile;
我收到的錯誤是:
ERROR 1: ALTER TABLE "soer_vd" ADD COLUMN "målsætning" CHAR(10) ERROR: invalid byte sequence for encoding "UTF8": 0xe56c73 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". ERROR 1: ALTER TABLE "soer_vd" ADD COLUMN "påvirkning" CHAR(10) ERROR: invalid byte sequence for encoding "UTF8": 0xe57669 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". ERROR 1: INSERT command for new feature failed. ERROR: invalid byte sequence for encoding "UTF8": 0xf8 HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".
目前,我的源文件是一個Shape文件,我敢肯定,它是Latin1的編碼。
我在這裏做錯了什麼,你能幫助我嗎?
親切的問候,卡斯帕
我已經嘗試了client_encoding和PGCLIENTENCODING來選擇編碼方案。他們都沒有解決我的問題。由於我還沒有找到一種方法來確定我的形狀文件的確切字符編碼,我嘗試了LATIN1,LATIN9,WIN1250和WIN1252,但仍然沒有成功。仍在尋找讓iconv工作...... – Chau 2009-09-07 09:05:39