I have a shapefile with the following structure:

enter image description here

enter image description here

I'm trying using ogr2ogr to import the above shapefile inside my PostGIS database with the following code:

ogr2ogr -append -f "PostgreSQL" PG:"host=localhost dbname=vector_data 
user=postgres password=postgres" 
grid.shp -a_srs EPSG:4326 -skipfailures -lco FID=ID 

The problem is when I run the above code, I get the following error message:

ERROR 1: Wrong field type for ID

I've understood the problem is because my ID field is a String and not an Integer, however I put COLUMN_TYPES=ID=VARCHAR on my script and ogr2ogr was not able to understand it.

I tried to import this shapefile using no field as FID and it worked, but I would like to import it in my database using ID as a primary key even it is a String.

Is there a way of doing it?

The shapefile is here: http://www.dpi.inpe.br/newcatalog/tmp/grades/grade_cbers4_mux.zip

  • In ArcGIS, "ID" is a phantom shapefile field -- it's just a row-number identifier (zero-based). If the dBase file actually has a field named "ID", it will get renamed to "ID_". You're much better off renaming the "ID" to be "MYID" than trying to change the type of a non-existant column.
    – Vince
    Commented Oct 30, 2019 at 20:32

2 Answers 2


I don't think there is a workaround to this. I'm having the same problem and I just ended up leaving the generated FID column as is and created an unique index on the column I wanted to create the primary key on.

If you don't really need a primary key but just an index and/or a unique constraint then just go that way.

I found this link where it has been reported as an issue 5 years ago but the ticket is qualified as a "wontfix" and closed : https://trac.osgeo.org/gdal/ticket/5654

  • 1
    Thank you for your explanation and tips, I am going to follow them. The fact they won't fix this issue is really sad, because I believe this resource would be a great one to ogr2ogr.
    – rmmariano
    Commented Oct 31, 2019 at 13:34

The specification:


works in the incaration of ogr2ogr dated GDAL 3.0.4, released 2020/01/28.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.