[postgis-users] Postgis to ESRI shape file encoding problem

85 views
Skip to first unread message

Ervin Ramonllari

unread,
Jul 18, 2008, 5:00:19 AM7/18/08
to postgi...@postgis.refractions.net
Hello everybody,

I'm trying to export some data from a Postgresql database encoded in UTF-8 into some ESRI shape files.
I'm using PostGIS Dumper (pgsql2shp).

the export is done correctly, but some special characters could not be exported properly. I guess it's a problem of encoding but I can't figure out how to deal with it.

I googled around but couldn't find something useful.

Any help for solving my problem would be highly appreciated,

thanks in advance,

Ervin.


Explore the seven wonders of the world Learn more!

Gabriel Messner

unread,
Jul 18, 2008, 6:33:55 AM7/18/08
to PostGIS Users Discussion
In wich language are data?

2008/7/18 Ervin Ramonllari <ervin.ra...@hotmail.com>:
_______________________________________________
postgis-users mailing list
postgi...@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Ervin Ramonllari

unread,
Jul 18, 2008, 6:39:10 AM7/18/08
to PostGIS Users Discussion
In Albanian, there are 4 special characters.




Date: Fri, 18 Jul 2008 12:33:55 +0200
From: gabme...@gmail.com
To: postgi...@postgis.refractions.net
Subject: Re: [postgis-users] Postgis to ESRI shape file encoding problem

Gabriel Messner

unread,
Jul 18, 2008, 7:24:28 AM7/18/08
to PostGIS Users Discussion
Try pgsql2shp option:

-W sq-iso-8859-1

2008/7/18 Ervin Ramonllari <ervin.ra...@hotmail.com>:

Ervin Ramonllari

unread,
Jul 18, 2008, 7:38:37 AM7/18/08
to PostGIS Users Discussion
I tried that,
it gives back an error. It doesn't recognize -W as an option or command.




Date: Fri, 18 Jul 2008 13:24:28 +0200

Connect to the next generation of MSN Messenger  Get it now!

Gabriel Messner

unread,
Jul 18, 2008, 7:52:22 AM7/18/08
to PostGIS Users Discussion
yes, you´re right; -W option only works with loader shp2pgsql.

The second option may be to define in the pgsql.conf file the following line:

client_encoding = sq-iso-8859-1 (i´not sure if Postgresql recognize the character encoding Latin1 for albanian as sq-iso-8859-1, but try with it or search the equivalent and write it in the pgsql.conf file). Afterwards, execute the dumper (pgsql2shp).



2008/7/18 Ervin Ramonllari <ervin.ra...@hotmail.com>:

Ervin Ramonllari

unread,
Jul 18, 2008, 8:54:37 AM7/18/08
to PostGIS Users Discussion
I tried that solution, but the result is the same as before.

Maybe I should get rid of those nasty characters before exporting to shape.

Thank you very much for your help.

Ervin.




Date: Fri, 18 Jul 2008 13:52:22 +0200

Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! Try it!

Armin Burger

unread,
Jul 19, 2008, 7:08:34 AM7/19/08
to PostGIS Users Discussion
If I remember well pgsql2shp creates a shapefile with the same encoding
(applied on the dbf file of it) as the database. The problem is that
clients may have problems with this encoding.

It's possible to export UTF-8 PG tables to shapefile which then also is
UTF-8 encoded. This is correctly read e.g. by Mapserver, but not for
most other clients I know (also not Opensource ones like JUMP, gvSig,
etc). For Albanian I would guess that ISO-8859-1 (Latin1) will not be
the right encoding, more something like ISO-8859-2 (Latin2).

If you database is in UTF-8 you should be able to export to a shapefile
with Latin2 encoding by converting the single columns to Latin2 with
specifying the SQL select command in pgsql2shp

pgsql2shp yourdatabase "select the_geom, convert(field1, 'UTF8',
'LATIN2'), field2 from ..."

If then your client program can interpret Latin2 correctly, which most
should be able to, you're done.

armin

On 18/07/2008 11:00, Ervin Ramonllari wrote:
> Hello everybody,
>
> I'm trying to export some data from a Postgresql database encoded in
> UTF-8 into some ESRI shape files.
> I'm using PostGIS Dumper (pgsql2shp).
>
> the export is done correctly, but some special characters could not be
> exported properly. I guess it's a problem of encoding but I can't figure
> out how to deal with it.
>
> I googled around but couldn't find something useful.
>
> Any help for solving my problem would be highly appreciated,
>
> thanks in advance,
>
> Ervin.
>

> ------------------------------------------------------------------------


> Explore the seven wonders of the world Learn more!

> <http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE>
>
>
> ------------------------------------------------------------------------

Steffen Macke

unread,
Jul 19, 2008, 8:37:37 AM7/19/08
to PostGIS Users Discussion
You can also try to set the environment variable PGCLIENTENCODING to the
encoding value you need (e.g. LATIN2).

Steffen

>> I'm trying to export some data from a Postgresql database encoded in UTF-8
>> into some ESRI shape files.
>> I'm using PostGIS Dumper (pgsql2shp).

Mark Cave-Ayland

unread,
Jul 21, 2008, 4:51:13 AM7/21/08
to PostGIS Users Discussion
Ervin Ramonllari wrote:
> I tried that,
> it gives back an error. It doesn't recognize -W as an option or command.

It would be a very useful (and rather simple) patch for someone to add a
-W option to pgsql2shp which would set the correct client encoding
before extracting the shapefile. Anyone interested? ;)


ATB,

Mark.

--
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063

Ervin Ramonllari

unread,
Jul 21, 2008, 6:33:54 AM7/21/08
to PostGIS Users Discussion
I tried this way :

ALTER DATABASE DBIPRS SET PGCLIENTENCODING to 'Latin2'

but i got the error:

ERROR: unrecognized configuration parameter "pgclientencoding"
SQL state: 42704



> Date: Sat, 19 Jul 2008 14:37:37 +0200
> From: sdte...@gmail.com

> To: postgi...@postgis.refractions.net
> Subject: Re: [postgis-users] Postgis to ESRI shape file encoding problem
>

Discover the new Windows Vista Learn more!

Maher Karim

unread,
Jul 21, 2008, 6:47:48 AM7/21/08
to PostGIS Users Discussion, postgis-users, postgis-users-bounces

Hello,
You have an error in this sentence, you should use it like this

ALTER DATABASE DBIPRS SET client_encoding=latin2;

Regards
Maher

|---------+--------------------------------------------->
| | Ervin Ramonllari |
| | <ervin.ra...@hotmail.com> |
| | Sent by: |
| | postgis-us...@postgis.refr|
| | actions.net |
| | |
| | |
| | 07/21/2008 01:33 PM |
| | Please respond to PostGIS Users |
| | Discussion |
|---------+--------------------------------------------->
>--------------------------------------------------------------------------------------------------------------------------------------------------|
| |
| To: PostGIS Users Discussion <postgi...@postgis.refractions.net> |
| cc: |
| Subject: RE: [postgis-users] Postgis to ESRI shape file encoding problem |
>--------------------------------------------------------------------------------------------------------------------------------------------------|

I tried this way :

ALTER DATABASE DBIPRS SET PGCLIENTENCODING to 'Latin2'

but i got the error:

ERROR: unrecognized configuration parameter "pgclientencoding"
SQL state: 42704

> Date: Sat, 19 Jul 2008 14:37:37 +0200
> From: sdte...@gmail.com
> To: postgi...@postgis.refractions.net
> Subject: Re: [postgis-users] Postgis to ESRI shape file encoding problem
>
> You can also try to set the environment variable PGCLIENTENCODING to the
> encoding value you need (e.g. LATIN2).
>
> Steffen
>
> >> I'm trying to export some data from a Postgresql database encoded in
UTF-8
> >> into some ESRI shape files.
> >> I'm using PostGIS Dumper (pgsql2shp).
> _______________________________________________
> postgis-users mailing list
> postgi...@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users

Discover the new Windows Vista Learn more!

Maher...@dorsch.com.jo

unread,
Jul 21, 2008, 7:48:20 AM7/21/08
to PostGIS Users Discussion, postgi...@postgis.refractions.net, postgis-us...@postgis.refractions.net

Hello,
You have an error in this sentence, you should use it like this

ALTER DATABASE DBIPRS SET client_encoding=latin2;

Regards
Maher



07/21/2008 01:33 PM
Please respond to PostGIS Users Discussion

        To:        PostGIS Users Discussion <postgi...@postgis.refractions.net>
        cc:        

        Subject:        RE: [postgis-users] Postgis to ESRI shape file encoding problem
Discover the new Windows Vista Learn more!_______________________________________________

Ervin Ramonllari

unread,
Jul 21, 2008, 9:34:31 AM7/21/08
to PostGIS Users Discussion
Ok, thnx
but i have tried this solution before.

It looks like a problem with the shape or most probably with the dbf file encoding. the dbf encoding should be SQL_ASCII.

Actually, if you try to save an Excel spreadsheet( which contains special character - Ë, Ç ) as a dbf file, the result is the same as in my exercise. The special characters can later be replace by using ArcView or ArcMap.


I just decided to remove my special characters from my database, so it's not a concern anymore (for this time, a solution has to be found anyway).

Just, for curiosity, has somebody had the same problem as mine?

Thanks to all you guys,

regards
Ervin





To: postgi...@postgis.refractions.net
CC: postgi...@postgis.refractions.net; postgis-us...@postgis.refractions.net

Subject: RE: [postgis-users] Postgis to ESRI shape file encoding problem
From: Maher...@dorsch.com.jo
Date: Mon, 21 Jul 2008 14:48:20 +0300
Reply all
Reply to author
Forward
0 new messages