I have a large dataset in a PostGIS database (OS MasterMap). My aim is to export specific areas of this dataset to DXF, while retaining the attributes of the data as layers in the DXF.
My current ogr2ogr command looks like this:
$ ogr2ogr -f "DXF" os_mm_export.dxf PG:"host=22.214.171.124 dbname=db user=user password=xxxxx" -sql "SELECT ST_INTERSECTION(a.the_geom, (SELECT ST_SETSRID(geom, 27700) FROM schema.site_boundary)) AS geom FROM tbl_os_mmap AS a WHERE ST_INTERSECTS(ST_SETSRID(a.the_geom, 27700), (SELECT ST_SETSRID(geom, 27700) FROM schema.site_boundary))"
This works fine to export the data to DXF from the specified area, but the DXF only comes out with a single layer '0'.
What I want is to specify a 'line type' field to be used to create layers in the DXF.
There are also points to be exported, for those tables I would like to be able to specify which field would be used to label the points.
I realise it would be possible to break the process down into multiple steps, but I'm interested to see if it would be possible to do both things in a single ogr2ogr command, as this would obviously be the fastest and most elegant solution.