PostGIS importing shapefile error w/ official manager

I'm having some trouble when trying to import an shapefile of the Sao Paulo Brazil's state (I downloaded it from the web and I'm using the own PostGis manager to import it).

Here's an image!

The connection is already on.

In the "Options" menu, i had to change from "UTF8" to LATIN1, cause if I didn't, I'd get this error message: "Unable to convert field name to UTF-8 (iconv reports "Illegal byte sequence"). Current encoding is "UTF-8". Try "LATIN1" (Western European), or one of the values described at"

I also wanted to now what is SRID and wich value should i put there.

When I changed to LATIN1, I get this other error message: "Failed in pgui_exec(): ERRO: sequência de bytes é inválida para codificação "UTF8": 0xe3 0xa7 0xe3". In english, it says the byte sequence is not valid to UTF8 codification.

I'm a bit desperate cause I've never used GIS before.

I was having a similar issue and I used the-W "latin1"option and when using and it took care of my issues:

shp2pgsql -I -W "latin1" -s 3857 mgau2013v6_0/agebs_urbanos_2013.shp public.mexico_shape_data | psql -d osm

I found that this was a helpful reference for the syntax:

For PostGIS, you can try to import with shp2pgsql.

Generic command :

shp2pgsql -s  -c -D -I  . | psql -d  -h  -U 

For example with Linux :

shp2pgsql -s 4326 -c -D -I /var/www/myshapetoimport.shp nameoftheshape | psql -d databasename -h localhost -U Postgres

You have to find out the correct encoding of the shapefile. Sometimes metadata aren't helpful at all and the only way is trial and error (try all common encodings for your language in Layer Properties dialog until the attribute data displays correctly in QGIS attribute table). Then, set this encoding while importing and the driver will convert it to UTF on the fly.

Sometimes the error isn't in the attribute value but in the attribute name. Be sure that attribute names don't have spaces or special characters.

I came across the same issue when I imported my shapefile into PostGIS because my column names have Chinese characters. I assume that caused the problem for encoding. After converting all the Chinese characters to English characters for all column names, I imported the data successfully.

Watch the video: How to Install and Setup PostgreSQL on Windows 10 (October 2021).