[postgis-users] Problem importing from coverage to postgres using ogr2ogr

Frank Warmerdam warmerdam at pobox.com
Thu Feb 7 14:55:36 PST 2008

Shona Talbot wrote:
> I don't know if this is a postgres or ogr2ogr issue, so I apologize if 
> I'm looking in the wrong place, but I recently ran into the following:
> I used this command to convert a coverage to a postgis database:
> */ogr2ogr -f "PostgreSQL" -lco precision=no PG:"host=mercator 
> user=postgres dbname=tembec5" phase4b/*
> There were no error messages, but any field that contained a dash 
> ("-")in the field name had no values in the postgres db..  It wasnt a 
> big deal, I just renamed the fields in Arc, and it worked fine. I only 
> wondered if anyone else had run into this, and if there might be a way 
> to prevent it other than renaming the field(s).


I believe the problem is that when the OGR PostGIS driver creates a field
it "launders" problematic names such as those containing a dash into a
form that uses an underscore instead.

But ogr2ogr's "feature copying" logic operates on the basis of field
names and it skips the fields with dashes because it can't find the
corresponding field in postgres.

Really, I think we need smarter logic in ogr2ogr for feature copying.

I'd appreciate it if you could file a ticket against GDAL/OGR on this
issue (copy in my reply if you would).

In the meantime, pre-laundering the field names as you have done is the
easiest work around.

Best regards,
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org

More information about the postgis-users mailing list