1

I am trying to load a shapefile to SQL Server, using ogr2ogr and Shape2SQL tools. The shapefile uses UTF-8 encoding, specified in a .cpg file, and confirmed when opening the file with QGIS.

However, as this post explains: Which character encoding is used by the DBF file in shapefiles? The .cpg file only applies for data, not column names. So both tools (ogr2ogr and shape2sql) fail when reading the file due to that reason.

I have tried converting the .dbf file to various formats (from plain ascii, to utf8 without bom, to utf8) using Notepad++ but with no results.

Is there any semi-automatic way to convert the column names to their latin equivalent, or force either of these programs to read column names in utf8?

nmtoken
13.6k5 gold badges39 silver badges91 bronze badges
asked Jun 8, 2015 at 7:42
2
  • What's your target: Postgres, MySQL, ...? Commented Jun 8, 2015 at 17:13
  • @underdark sql server 2008 r2 Commented Jun 8, 2015 at 21:58

1 Answer 1

2
  1. make sure your table uses UTF-8 encoding
  2. this command works for me in windows:

    ogr2ogr -f "MySQL" MYSQL:"db_name,host=localhost,user=root,password=root,port=3306" -nln "table" -a_srs "EPSG:4326" c:\a.shp -lco ENGINE=MyISAM

Kirk Kuykendall
25.8k9 gold badges68 silver badges155 bronze badges
answered Sep 26, 2015 at 12:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.