Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I really need to export, by the ogr2ogr command or similar, text information related to a geometry position from my PostgreSQL(with PostGIS) database to an AutoCAD DXF layer file or to a Microstation DGN layer file, so I can later show that information in the AutoCAD/Microstation GIS.

I have been looking through internet for so many days but all I can get is a layer with geometry points, I always lose the text label information. I know there is the "Text" element type in DGN and the "MTEXT/TEXT" element type in DXF, so I need to generate that kind of features.

In Shapefiles I know that I can export new attribute fields with that information but it have to be obtained in DXF/DGN format.

I need to made it automatic with some kind of server command like GDAL ogr2ogr, but I have tried with the "-select" (getting the text SQL SELECT attribute) or "-lco" or "-dsco" options without any result...

Those are my commands:

ogr2ogr -select "Text" -f DXF text_layer.dxf "PG:host=192.168.1.* user=**** password=**** dbname=****" -sql "SELECT position AS the_geom, name as Text FROM the_geometry_table"

ogr2ogr -select "Text" -f DGN text_layer.dgn "PG:host=192.168.1.* user=**** password=**** dbname=****" -sql "SELECT position AS the_geom, name as Text FROM the_geometry_table"

Any help? Thank you very much:)

share|improve this question
up vote 3 down vote accepted

From the OGR DXF Driver document, dxf driver

Point features with LABEL styling are written as MTEXT entities based on the styling information.

The OGR Feature Style is available here, OGR Style guide ,look for - Label Tool Parameters.

To define the Label style:

You can add a field named OGR_STYLE to your Postgresql table and populate with something like this, "LABEL(f:"Times New Roman",s:12pt,t:{text_string})"
text_string is the field you want to display as text in the DXF.

When you run ogr2ogr to convert your Point geometry to DXF, ogr should automatically detect OGR_STYLE and output MText in the dxf.

share|improve this answer
Oh yeah! It works, thank you klewis, it was much time spent.. Finally I decided to generate de OGR_STYLE field in the SQL query like: SELECT posicion AS the_geom, 'LABEL(f:\'Times New Roman\',s:12pt,t:\'' || name || '\')' AS OGR_STYLE FROM the_geometry_table c [...], and it became the Text attribute of the DXF Point object :) – Aleix Oct 7 '13 at 8:27

Your Answer


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.