4

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

4
  • did you try to change the value for "DBF file character encoding" under Options? It should match the encoding of your dbf file. Commented Feb 15, 2017 at 12:02
  • Yes, I also tried to change the dbf file character encoding under options. But, no luck.
    – LSG
    Commented Feb 15, 2017 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.
    – Regina Obe
    Commented Feb 15, 2017 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
    Commented Feb 16, 2017 at 9:39

1 Answer 1

8

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 and acknowledge you have read our privacy policy.

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