SV: [gdal-dev] PostgreSQL, PostGIS and ogr2ogr

Guillaume Sueur no-reply at neogeo-online.net
Tue Sep 8 08:07:38 EDT 2009


sure, you can define client_encoding direcly in postgresql.conf

regards

Guillaume

Casper Børgesen a écrit :
> A small follow-up. As I stated previously, the '--config PGCLIENTENCODING format' didn't help me. But calling 'SET PGCLIENTENCODING=LATIN1' before the call to ogr2ogr, did do the trick. Thus my shape file character encoding probably is LATIN1. 
> 
> Do you have any idea of how to get the '--config' method to work?
> 
> Regards, Casper
> 
> -----Oprindelig meddelelse-----
> Fra: gdal-dev-bounces at lists.osgeo.org [mailto:gdal-dev-bounces at lists.osgeo.org] På vegne af Casper Børgesen
> Sendt: 7. september 2009 08:57
> Til: gdal-dev at lists.osgeo.org
> Emne: SV: [gdal-dev] PostgreSQL, PostGIS and ogr2ogr
> 
> Okay and thank you for your answers! 
> 
> Since using the '--config PGCLIENTENCODING format' option didn't make a difference, my next guess is that the encoding of the shapefile might be the problem. I have used SQL_ASCII, LATIN1, LATIN9, WIN1250, WIN1252 as formats and I still get the error. The formats has been selected according to my location (Denmark).
> 
> Do you have any suggestions to how I should proceed?
> 
> -----Oprindelig meddelelse-----
> Fra: Even Rouault [mailto:even.rouault at mines-paris.org]
> Sendt: 4. september 2009 16:28
> Til: Casper Børgesen
> Cc: gdal-dev at lists.osgeo.org
> Emne: Re: [gdal-dev] PostgreSQL, PostGIS and ogr2ogr
> 
> 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
>>
>>
> 
> 
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
> 
> 


More information about the gdal-dev mailing list