I have been using ogr2ogr GDAL tool to migrate geospatial data from DXF file to PotgresQL database without much problems. But now there is a special problem I can not fix.

I have a DXF file with LINESTRINGs that when I import them to the PostgreSQL database some of the linestrings are imported in the correct geometric coordinates but some other LINESTRINGs are imported with the negative longitude, so that LINESTRINGs are mirrored to the west.

When I open the DXF file with my QUANTUM GIS viewer I can see all the LINESTRINGs together with the correct coordinates, but when I export them to the postgres database and I print them in a map (by a web application) or later I export then I see some of the LINESTRINGs mirrored "away home" from the original coordinates.

That is my ogr2ogr commandline:

ogr2ogr -select "" -f PostgreSQL "PG:host=192.168.*.* user=**** password=**** dbname=****" C:\PATH\FILE.dxf -s_srs "EPSG:23031" -a_srs "EPSG:23031" -lco GEOMETRY_NAME=the_geom -nlt LINESTRING

There is no error output from the ogr2ogr tool, so it is difficult to get the reason of that problematic.

Any help or recommendation?

I have tried without much effect the ogr2ogr opions: -lco GEOM_TYPE=geometry -lco DIM=2 --config PG_USE_COPY YES -lco PRECISION=YES -clipsrc xmin ymin xmax ymax

1 Answer 1


I can't find the origin of this problem but I finally reached the final objective through another tool, with the GIS:

1) open the DXF file with QGIS

2) convert the DXF to Shapefile (right click on the layer > "Save as...")

3) use the Shapefiles to PostgreSQL converter in the menu option: Database > Split > "Import Shapefiles to PostgreSQL"

Trough this tool I imported the DXF to PostgreSQL without the wrong coordinates problem. I suppose that in the DXF to Shapefiles conversion the origin of the problem is solved.

If anyone have more information about what can origin that situation when I use the ogr2ogr tool it would be nice to know, because right know I cannot make that conversion (DXF to PostgreSQL) automatic (with an script that would execute the ogr2ogr command).

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.