[GIS] ogr2ogr convert DXF to GeoJSON with defined geometry

dxfgeojsonogrogr2ogr

I trie to convert a DXF file into a GeoJSON file with:

ogr2ogr -f 'GeoJSON' -sql "SELECT * FROM entities WHERE layer = 'geom_test'" test.json dfxtest.dxf

Is it possible to convert only geometries with for example the type point?

Are there documentations or explanations on how to use ogr2ogr with dxf?

Best Answer

GDAL supports two SQL dialects: the default OGR dialect and an alternative SQLite (Spatialite) dialect. Both dialect support selecting geometries by geometry type. Ogrinfo tool is recommended for experiments because by using it the possible troubles with writing the result out can be avoided. If output from ogrinfo is good then the reading side is OK too.

http://www.gdal.org/ogr_sql.html

http://www.gdal.org/ogr_sql_sqlite.html

Making a selection by geometry type with the OGR SQL dialect:

ogrinfo -sql "select * from entities where Layer='New' and OGR_GEOMETRY='POINT'" dxftest.dxf

Making a selection by geometry type with the SQLite SQL dialect:

ogrinfo -dialect sqlite -sql "SELECT * FROM entities WHERE layer='New' and GeometryType(geometry)='POINT'" dxftest.dxf