I am trying to find a way to convert a DXF into a GeoJSON and keeping the style information (linecolor etc) in the properties for example.
currently I convert it like so:
get the layers:
LAYERS=$(ogrinfo input.dxf -sql "SELECT DISTINCT Layer FROM entities" | grep "Layer (String)" | awk '{print $4}' | sed "s/^/'/" | sed "s/$/'/" | tr '\n' ',' | sed 's/,$//') and then the conversion is like this:
ogr2ogr -f "GeoJSON" output.geojson input.dxf \ -dialect sqlite \ -sql "SELECT * FROM entities WHERE Layer IN ($LAYERS)" \ -t_srs EPSG:4326 -s_srs EPSG:25833 \ -oo DXF_CLOSED_LINE_AS_POLYGON=YES features from the GeoJSON look like this:
{ "type": "Feature", "properties": { "Layer": "026_TOPOGRAPHIE", "PaperSpace": null, "SubClasses": "AcDbEntity:AcDbPolyline", "Linetype": null, "EntityHandle": "158C52", "Text": null }, "geometry": { "type": "LineString", "coordinates": [ [ 1234,1234 ], [ 1234,1234 ] ] } }, when I do:
ogrinfo 753860_Bestand.dxf -sql "SELECT * FROM entities" i get all elements from the dxf including a Style. one for example looks like this:
OGRFeature(entities):25848 Layer (String) = 0 SubClasses (String) = AcDbEntity:AcDbText:AcDbAttribute EntityHandle (String) = 16D2ED Text (String) = Lichtmast mit Aufsatzleuchte Style = LABEL(f:"Arial",t:"Lichtmast mit Aufsatzleuchte",p:1,s:1g,c:#00000000) POINT Z (379656.122 5822998.987 0) or like this:
OGRFeature(entities):7008 Layer (String) = 011_GEBAEUDE_FLAECHE SubClasses (String) = AcDbEntity:AcDbHatch EntityHandle (String) = 15CB17 Text (String) = ANSI31 Style = BRUSH(fc:#dcdcdc) POLYGON ((380803.095 5823145.483,380803.766 5823138.454,380793.301 5823137.492,380792.552 5823144.536,380803.095 5823145.483)) so it can read the information! But any idea how and where I would get the line styling into the GeoJSON properties?
ogr2ogr -f "GeoJSON" output.geojson output.dxf -dialect sqlite -sql "SELECT Layer, EntityHandle, Text, OGR_STYLE, * FROM entities"it generates a property:"OGR_STYLE": "LABEL(f:\"Arial\",t:\"69\",p:1,s:0.75g,c:#00000000)"in the geojson