Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Hi 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 qgis, and save as shp 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 advise?

  • Niels
share|improve this question

1 Answer 1

up vote 0 down vote accepted

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

share|improve this answer
1  
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 '13 at 11:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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