3

I need a little help/ ideas on how to convert tab files.

The problem: I have many TAB files produced daily by 3 party app, I need to batch import the files into postgres.

Most files import fine, however some files has mixed content like linestrings and multilinestrings in one file.

I can't import that type of files.

I can open the files in qQGIS, and save as a shapefile and then import to the database, but it needs to be done in a batch job.

This is what I'm using and what is working for files that only has linestrings.

C:\Program Files (x86)\FWTools2.4.7\bin>ogr2ogr -skipfailures -overwrite -t_srs "EPSG:4326" -s_srs "EPSG:4326" -a_srs "EPSG:4326" -f "PostgreSQL" PG:"host=localhost user=zzz dbname=geo password=zzz" C:\gisdata\Cables_1.tab -nln tmpimport.Cables_1
This is the error I get when importing a mixed content file
Warning 1: Geometry to be inserted is of type Multi Line String, whereas the layer geometry type is Line String.
Insertion is likely to fail
ERROR 1: INSERT command for new feature failed.
ERROR: Geometry type (MultiLineString) does not match column type (LineString)

Anyone has any advice?

1 Answer 1

1

So what do you do with the Multi Line Strings that aren't imported? Are you just ignoring these?

You could change the Geometry type of your column to also allow MultiLineString

Peter

1
  • 2
    Hi Peter, setting -nlt GEOMETRY fixed the problem. Thanks. ogr2ogr -skipfailures -overwrite -t_srs "EPSG:4326" -s_srs "EPSG:4326" -a_srs "EPSG:4326" -nlt GEOMETRY -f "PostgreSQL" PG:"host=localhost user=zzz dbname=geo password=zzz" C:\gisdata\Cables_1.tab -nln tmpimport.Cables_1
    – dk_nls
    May 3, 2013 at 11:24

Your Answer

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

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