Wednesday, 7 December 2016

shapefile - How to import using shp2pgsql?


I want to import shapefile into PostGIS. There is one database postgres in it but no table added yet.



I am using this command:


shp2pgsql -I -s 4326 districts.shp districts | psql -d postgres -U postgres 

and it's giving me some error:



Unable to convert data value to UTF-8 (iconv reports "Invalid or incomplete multibyte or wide character"). Current encoding is "UTF-8". Try "LATIN1" (Western European), or one of the values described at postgresql.org/docs/current/static/multibyte.html



Is my command wrong ??



Answer



Have you tried -W "latin1" flag? Sometimes the default encoding (UTF-8) doesn't work well. Maybe you'll have better luck with latin1 encoding:



shp2pgsql -I -s 4326 -W "latin1" districts.shp districts | psql -d postgres -U postgres

There's a useful cheat-sheet available here.


Hope it helps..


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...