Bug report #7910

DXF file can't be saved as SHP

Added by John Sankey over 11 years ago. Updated over 10 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Vectors
Affected QGIS version:1.8.0 Regression?:No
Operating System:Mac OSX Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16782

Description

I've got a DXF file:
Storage type of this layer: DXF
Source for this layer: /Users/john/QGIS/OVPP/OAK VALLEY Drawing.dxf
Geometry type of the features in this layer: Line
The number of features in this layer: 1708
Editing capabilities of this layer:
Extents:
In layer spatial reference system units : xMin,yMin -357.179,-760.168 : xMax,yMax 16008.1,6793.72
Layer Spatial Reference System:
+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

It displays on the screen partly correctly - line features are shown correctly but all labels, such as in legends, are replaced by a single line for each label.

When I save as SHP, it creates:
Storage type of this layer: ESRI Shapefile
Source for this layer: /Users/john/QGIS/OVPP/oakvalley.shp
Geometry type of the features in this layer: Line
The number of features in this layer: 0
Editing capabilities of this layer: Create Spatial Index, Fast Access to Features at ID, Change Geometries
Extents:
In layer spatial reference system units : unknown extent
Layer Spatial Reference System:
+proj=utm +zone=18 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

OAK_VALLEY_Drawing.dxf (670 KB) John Sankey, 2013-05-26 09:02 AM

test.tar.gz (181 KB) Giovanni Manghi, 2013-05-26 12:05 PM

OAK_VALLEY_A1_Drawing-Model.pdf - AutoCAD sees this (155 KB) John Sankey, 2013-05-26 10:15 PM

ovpp.gif - what QGIS sees (12.5 KB) John Sankey, 2013-05-26 10:15 PM

OAK.zip (185 KB) Alessandro Ciali, 2013-05-27 12:46 AM

OAK_VALLEY_Drawing.dwg - native AutoCAD save file (166 KB) John Sankey, 2013-05-27 04:55 AM

OAK_VALLEY_Drawing_text2.zip (9.28 KB) Alessandro Ciali, 2013-05-27 07:06 AM

OAK2.zip (103 KB) Alessandro Ciali, 2013-05-27 11:50 PM

History

#1 Updated by Giovanni Manghi over 11 years ago

  • Status changed from Open to Feedback
  • File test.tar.gz added

on QGIS master it gives error while exporting to shape, but it gives also a result (attached). Please try and report back. Cheers.

Export to vector file failed.
Error: Feature write errors:
Feature creation error (OGR error: Attempt to write non-linestring (POINT) geometry to ARC type shapefile.)
...
Feature creation error (OGR error: Attempt to

#2 Updated by John Sankey over 11 years ago

DXF can contain points, lines and polygons - this one comes from an AutoCAD user. (So can WKT, which I also tried to use for another user's maps earlier - see #7703.) QGIS needs to creat three layers for this DXF, one pont, one line, one polygon. It doesn't, and that's why it fails. This is not only a bug, but a blocker for bringing in these AutoCAD maps. I attach a PDF from the user showing what the result should look like, also a GIF of what I get in QGIS 1.8 with this file.

#3 Updated by Alessandro Ciali over 11 years ago

I tried to import the dxf file as it is, obtaining the same error. but, performing the following feature subset:
"SubClasses" = 'AcDbEntity:AcDbLine' OR "SubClasses" = 'AcDbEntity:AcDbPolyline' OR "SubClasses" = 'AcDbEntity:AcDbCircle' OR "SubClasses" = 'AcDbEntity:AcDbCircle:AcDbArc'
and then saving layer as shape, I obtained the polyline shape attached.
Performing a feature subset:
"SubClasses" = 'AcDbEntity:AcDbText'
In order to isolate the only text features, I was able to correctly represent text in QGIS, but when I tried to export the layer as shape, I was prompted by: |Export to vector file failed. |Error: Feature write errors
reported in your previous messages. It seems that QGIS tries to import text layer in a line shape: |Feature creation error (OGR error: Attempt to write non-linestring (POINT) geometry to ARC type |shapefile.)
regardless of text layer feature type (point, see the project attached); this can be the problem.
BTW, I can't open the dwg file in autocat (autocad LT 2009), so check the Autocad version, It could be an unsupported one.
Please, give a feedback so that we can refine the problem

#4 Updated by John Sankey over 11 years ago

I've asked the user for his version. In the meantime, here is the native DWG of AutoCAD.
The drawing was originally in Drafix CAD - it was bought by AutoCAD and shut down; the user migrated to AutoCAD Lt 2008 which is what has produced his DWG and DXF.

#5 Updated by Alessandro Ciali over 11 years ago

I exported the DWG to dxf2000 version. I exported then to shp without problem (see attached shape).
The problem was surely related to dxf version. Used QGIS current master, but it works the same with 1.8

In order to correctly export dxf layer to shape, I suggest to follow these steps:

1. open dxf in QGIS;
2. make a feature subset depending on type of feature you are interested (then, you have to reset the symbology type (point, line, area), maybe it could not be the right one);
3. Save as the layer

I think that you can close this ticket.

#6 Updated by John Sankey over 11 years ago

Alessandro, how do I do step 2 within a DXF layer? (With 1700+ features, it can't be one by one...)

Also, when I save-as there is no option to set SHP type to point,line or polygon - I can only do that when I create a new SHP.

#7 Updated by Alessandro Ciali over 11 years ago

1. About step 2: in layer properties you can find Feature subset. You have not to do one by one, but define a query on "Subclasses" field of dxf layer like: |"SubClasses" = 'AcDbEntity:AcDbLine'
2. There is no option to set SHP type on save as, the type is automatically determined on the type of feature you are saving. That's why you have to make a subset query on the feature type before save.

#8 Updated by John Sankey over 11 years ago

Alessandro, I can't find anything about this in the user manual. I tried the exact phrase you quote and it wiped out many of the lines as well as all points and labels. What are the subclass statements for Polygons, Points, multiline, multipoint etc.? And, how do I get labelled points, which are most of the features on this map?

This is definitely a workaround method, not one that should be considered as final in a stable version of QGIS...

#9 Updated by Alessandro Ciali over 11 years ago

Hi jhon, the user manual does not contain anything about this because this is a workaround that I use for representing CAD drawing in QGIS. I found this way through some attemps. I attached a QGIS project, you have only to reconnect the dxf you find to the project. See how I have represented the different layers (based from different subclesses of the same dxf file).

#10 Updated by Giovanni Manghi over 11 years ago

This is definitely a workaround method, not one that should be considered as final in a stable version of QGIS...

There are well known issues around DXF files, please see

http://lists.osgeo.org/pipermail/qgis-developer/2013-February/024592.html

and add your notes. Cheers!

#11 Updated by John Sankey over 11 years ago

Hi all: please do not close this thread. Here's why:

Until very recently GIS systems were far too expensive for individual professionals - of course I thank all those working on QGIS for dramatically changing that. What it meant was that all of us involved in mapping looked for an affordable system, usually one we needed for other work, that allowed numeric data from field surveys to be entered. I started in the '60s with Fortran programs I wrote myself, and transitioned to the 1980's SigmaPlot when it became available. The output of many, such as SigmaPlot, can be converted with a script to WKT - but see #7703 for my problems with that. The next person I tried used AutoCAD, which outputs in DWG (closed, proprietary i.e. useless for open source) and DXF; you can see here the problems with it. I'm certain the next user I try will use yet another available numeric-based system.

QGIS needs to work on dealing with these old ersatz methods to allow us all to move to the far superior control of output that a true GIS gives. But in particular, it needs to provide continuing solid support for numerical data from surveys - these continue to be produced by all surveyors.

WKT would probably be the most flexible if someone would be willing to work on it to make it solid, as it's easily written directly by anyone with survey data in hand - most of us keep our fieldbooks. My most recent user has his original survey data, so it might well be easier for me to rewrite it in WKT rather than deal with the uncertainties of unknown-vintage DXF or who knows what next format.

Many thanks all - I'll do my best to work with Alessandro's work.

#12 Updated by Jürgen Fischer over 10 years ago

  • Status changed from Feedback to Closed
  • Category set to Vectors

Also available in: Atom PDF