0

I tried to import a shapefile to postgresql. I used PostGIS shapefile import/export manager. Earlier I have done same thing but did not face any problem. But this time I am facing problem with encoding. First I tried to import into an exsisting database with UTF-8 encoding. It showed following error:

Shapefile type: Polygon
PostGIS type: MULTIPOLYGON[2]
Unable to convert data value to UTF-8 (iconv reports "Invalid argument"). 
Current encoding is "UTF-8". Try "LATIN1" (Western European), or one of the 
values described at http://www.postgresql.org/docs/current/static/multibyte.html.

Shapefile import failed.

So, I created another database with 'LATIN1' encoding with collation C and character type C. Then tried to set client encoding to 'LATIN1' by executing the following query.

set client_encoding='LATIN1';

Now tried to import. But still it is showing client encoding is UTF-8 and import fails. Screen shot is attached. What to do?

Screen shot of shapefile loader

  • did you try to change the value for "DBF file character encoding" under Options? It should match the encoding of your dbf file. – Andreas Müller Feb 15 '17 at 12:02
  • Yes, I also tried to change the dbf file character encoding under options. But, no luck. – LSG Feb 15 '17 at 12:08
  • Can you provide the file you are trying to import. I can take a look at it to make sure it's nothing wrong with importer. Also note the version of loader you are using - click the About button to see. – LR1234567 Feb 15 '17 at 13:07
  • I can't disclose the shapefile, sorry. Anyway I am new to postgres. Can you please tell me how to import using command line instructions instead of postgis shapefile import/export manager? – LSG Feb 16 '17 at 9:39
2

I was facing the same problem last days, and that was due to german letters in shapefile attribute table, so for that I did the following:

Simply, just click on option button and change UTF-8 to LATIN1enter image description hereenter image description here

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.