[gdal-dev] PostgreSQL, PostGIS and ogr2ogr

Even Rouault even.rouault at mines-paris.org
Fri Sep 4 10:28:09 EDT 2009


Selon Casper Børgesen <cbo at le34.dk>:

I'm not sure about options='-c client_encoding=latin1', but setting
PGCLIENTENCODING=LATIN1 instead as an environmnent variable/configuration option
should definitely work (provided that the source shape is effectively LATIN1
encoded)

ogr2ogr --config PGCLIENTENCODING LATIN1 -f PostgreSQL PG:"host=localhost
user=username dbname=dbname password=password" sourcefile


> Hi folks!
>
> I hope you can help me. I have searched google for answers, but haven't found
> any. So I thought going closer to the 'source' might help me.
>
> In my organisation, we work with various GIS data in different file formats.
> I have a project, where I need to put all these data into a PostGIS database.
> So far I'm using the command line tool ogr2ogr to inject the data. But I have
> problems with character encoding:
>
> ERROR 1: INSERT command for new feature failed.
> ERROR: invalid byte sequence for encoding "UTF8": 0xf8
> HINT: This error can also happen if the byte sequence does not match the
> encoding expected by the server, which is controlled by "client_encoding".
>
> My PostGIS database uses UTF-8 and the data I'm working with (shape) is
> probably Latin1 encoded.
>
> I found a discussion where a user suggests that the solution might be to do
> the following:
>
> ogr2ogr -f PostgreSQL PG:"host=localhost user=username dbname=dbname
> password=password options='-c client_encoding=latin1'" sourcefile;
>
> It does not seem to affect the injection. So, what am I doing wrong?
>
> Kind regards, Casper
>
>




More information about the gdal-dev mailing list