Opened 5 years ago

Closed 5 years ago

#5596 closed defect (invalid)

Unable to export Labels from postgis to dxf with ogr2ogr

Reported by: skalla Owned by: warmerdam
Priority: highest Milestone:
Component: Utilities Version: unspecified
Severity: critical Keywords:


How would I convert postgis data to DXF with ogr2ogr (including label). I am unable to export the label, just the feature. Example would be appreciated.

What I tried was: ogr2ogr -t_srs "EPSG:4326" -s_srs "EPSG:4326" -f "DXF" "test.dxf" PG:"host=localhost port=5432 user={pguser} dbname={dbname} password={pgpassw}" -sql "SELECT 'LABEL(f:\"Arial\",s:1.5g,t:\"SOMETHING\")' AS OGR_STYLE, the_geom FROM atr_ervenlines" -lco GEOMETRY_NAME=the_geom

Change History (1)

comment:1 Changed 5 years ago by Jukka Rahkonen

Resolution: invalid
Status: newclosed

Documentation without examples is rather useless indeed, I had to spend more than an hour before I managed to get some good output even I do have more experience than average GDAL users.

The important points: 1) Output layer must be a point layer 2) Label must be found from the input data from field named "OGR_STYLE" 3) Do not care about "ERROR 1"

ogr2ogr -f dxf -dialect sqlite temppoint1.dxf temppoint1.shp -sql
 "SELECT 'LABEL(f:\"Arial\",s:1.5g,t:\"SOMETHING\")' AS OGR_STYLE, geometry FROM
ERROR 1: DXF layer does not support arbitrary field creation, field 'OGR_STYLE'
not created.

Test the result:

ogrinfo -al temppoint1.dxf
INFO: Open of `temppoint1.dxf'
      using driver `DXF' successful.

Layer name: entities
Geometry: Unknown (any)
Feature Count: 29
Extent: (37.769932, 43.020021) - (43.878706, 47.509980)
Layer SRS WKT:
Layer: String (0.0)
SubClasses: String (0.0)
ExtendedEntity: String (0.0)
Linetype: String (0.0)
EntityHandle: String (0.0)
Text: String (0.0)
  Layer (String) = 0
  SubClasses (String) = AcDbEntity:AcDbMText
  ExtendedEntity (String) = (null)
  Linetype (String) = (null)
  EntityHandle (String) = 20000
  Text (String) = SOMETHING
  Style = LABEL(f:"Arial",t:"SOMETHING",s:1.5g,c:#000000)
  POINT (42.7200174548109 43.9099670604134)

Closing this ticket as invalid. Feel free to create a new ticket about improving the documentation of the DXF driver. We will thank you very much if you'll attach good, tested examples to the ticket. You can also write something to the wiki.

Note: See TracTickets for help on using tickets.