You must convert the "description" field of your csv file into label annotation following the DGAL OGR Feature Style specification http://www.gdal.org/ogr_feature_style.html. See a text label example from the section 2.1
A text label, taking the text string from the "text_string"
attribute field:
"LABEL(f:"Times New Roman",s:12pt,t:{text_string})"
It is not obvious how such OGR Style string can be build from CSV so it is best to give an example.
Step 1: Have data. Save the following as "opua.csv"
point#,x,y,z,description
1,0,0,122,name_1
2,1,1,222,name_2
Step 2: Make VRT. Reusing your VRT as such:
<OGRVRTDataSource>
<OGRVRTLayer name="opua">
<SrcDataSource>opua.csv</SrcDataSource>
<GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
<GeometryField encoding="PointFromColumns" x="X" y="Y" z="Z"/>
<Field name="id" type="String"/>
<Field name="description"/>
</OGRVRTLayer>
</OGRVRTDataSource>
Step 3: Use some SQL magic
Test with ogrinfo
ogrinfo -dialect sqlite -sql "SELECT 'LABEL(f:\"Arial\",s:1.5g,t:'||description||')' AS OGR_STYLE, geometry FROM opua" opua.vrt
Result:
INFO: Open of `opua.vrt'
using driver `OGR_VRT' successful.
Layer name: SELECT
Geometry: Point
Feature Count: 2
Extent: (0.000000, 0.000000) - (1.000000, 1.000000)
Layer SRS WKT:
GEOGCS["WGS 84",
DATUM["WGS_1984",
SPHEROID["WGS 84",6378137,298.257223563,
AUTHORITY["EPSG","7030"]],
AUTHORITY["EPSG","6326"]],
PRIMEM["Greenwich",0,
AUTHORITY["EPSG","8901"]],
UNIT["degree",0.0174532925199433,
AUTHORITY["EPSG","9122"]],
AUTHORITY["EPSG","4326"]]
Geometry Column = GEOMETRY
OGR_STYLE: String (0.0)
OGRFeature(SELECT):0
OGR_STYLE (String) = LABEL(f:"Arial",s:1.5g,t:name_1)
Style = LABEL(f:"Arial",s:1.5g,t:name_1)
POINT (0 0 122)
OGRFeature(SELECT):1
OGR_STYLE (String) = LABEL(f:"Arial",s:1.5g,t:name_2)
Style = LABEL(f:"Arial",s:1.5g,t:name_2)
POINT (1 1 222)
Looks good, try conversion into DXF
ogr2ogr -f DXF -dialect sqlite -sql "SELECT 'LABEL(f:\"Arial\",s:1.5g,t:'||description||')' AS OGR_STYLE, geometry FROM opua" opua.dxf opua.vrt
An error message "ERROR 1: DXF layer does not support arbitrary field creation, field 'OGR_STYLE' not created." appears but it is misleading in this context. OGR_STYLE does not get created but it is still converted into DXF style. Test it
ogrinfo opua.dxf entities
INFO: Open of `opua.dxf'
using driver `DXF' successful.
Layer name: entities
Geometry: Unknown (any)
Feature Count: 2
Extent: (0.000000, 0.000000) - (1.000000, 1.000000)
Layer SRS WKT:
(unknown)
Layer: String (0.0)
SubClasses: String (0.0)
ExtendedEntity: String (0.0)
Linetype: String (0.0)
EntityHandle: String (0.0)
Text: String (0.0)
OGRFeature(entities):0
Layer (String) = 0
SubClasses (String) = AcDbEntity:AcDbMText
ExtendedEntity (String) = (null)
Linetype (String) = (null)
EntityHandle (String) = 20000
Text (String) = name_1
Style = LABEL(f:"Arial",t:"name_1",s:1.5g,c:#000000)
POINT (0 0 122)
OGRFeature(entities):1
Layer (String) = 0
SubClasses (String) = AcDbEntity:AcDbMText
ExtendedEntity (String) = (null)
Linetype (String) = (null)
EntityHandle (String) = 20001
Text (String) = name_2
Style = LABEL(f:"Arial",t:"name_2",s:1.5g,c:#000000)
POINT (1 1 222)
At least GDAL finds the label from DXF. You can also notice that point geometries were stored and XYZ. However, I do not know DXF and I am not sure if label is stored correctly. By opening the DXF file I could see that label tests are stored into MTEXT like here:
MTEXT
5
20000
8
0
100
AcDbEntity
100
AcDbMText
40
1.5
1
name_1
10
0
20
0
30
122
0