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?

  • What's your target: Postgres, MySQL, ...? – underdark Jun 8 '15 at 17:13
  • @underdark sql server 2008 r2 – pkExec Jun 8 '15 at 21:58
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.