this is my first question on Stackexchange. I use a GPS to capture data in .dxf, manipulate it in a CAD program that I know how to use, then the dxf2shp converter (I think Python is mentioned) to let me generate .shp files for the end user. Every time I've done this recently I've got a meesage from QGIS that it has stopped working and will close. I've tried re-installing QGIS (1.8.0), but still have the same message. Am I doing something wrong or is this a known problem. Please note I'm not really computer literate, so if you could avoid assuming I know what a technical term means, i'd be grateful.
[GIS] QGIS crashes when using dxf to shp converter
pluginsqgis
Related Solutions
First you need to project your geographic coordinates to a cartesian 2D coordinate system, since affine transformations don't apply to geographic coordinate systems.
You can apply an affine transformation from control points or from transformation parameters. The QGIS plugin asks you transformation parameters, but it is much more common for a user to have control points.
From control points you can calculate transformation parameters. For an affine transformation there are 6 transformation parameters, so you need at least 3 control points (each control point implies 4 coordinates: Xsource, Ysource, Xtarget, Ytarget), but more control points are recommended to have redundancy and thus be able to apply Least Squares, which would give you an estimation of the transformation's quality. Remember that affine transformations can rotate, shift, scale (even applying different factors on each axis) and skew geometries.
Control points must have the form:
X SOURCE: Xs
Y SOURCE: Ys
X TARGET: Xt
Y TARGET: Yt
Parameters are:
a: Scale X
e: Scale Y
d: Rotation X
b: Rotation Y
c: Translation X
f: Translation Y
And we know:
Xt = X*a + Y*b + c
Yt = X*d + Y*e + f
So, you need to solve this system of equations (for 3 control points):
¦ Xs1 Ys1 1 0 0 0 ¦ | a ¦ ¦ Xt1 ¦
¦ Xs2 Ys2 1 0 0 0 ¦ ¦ b ¦ ¦ Xt2 ¦
¦ Xs3 Ys3 1 0 0 0 ¦ ¦ c ¦ = ¦ Xt3 ¦
¦ 0 0 0 Xs1 Ys1 1 ¦ ¦ d ¦ ¦ Yt1 ¦
¦ 0 0 0 Xs2 Ys2 1 ¦ ¦ e ¦ ¦ Yt2 ¦
¦ 0 0 0 Xs3 Ys3 1 ¦ ¦ f ¦ ¦ Yt3 ¦
Where parameters a, b, c, d, e, and f are unknown.
Once you calculate parameters a, b, c, d, e, and f, (for example with this online equation solver) place them into the QGIS plugin interface like this:
X' = a*x + b*y + c
Y' = d*x + e*y + f
or:
I think this solves your two questions.
Opening the dxf with Add Vector layer
and labelling with text
datafield gives almost the same as Autodesk Design Review:
The DXF file contains points and polygons in the same layer. This is not allowed in shapefiles. That is why you can not save it as a shapefile.
Exporting as kml will work, as this format supports different geometry types.
You have to set NameField=Text
in the Data Source
Field to preserve the text into the Name field for labelling.
EDIT
You can export the data as lines shapefile, and ignore the error messages. In a second run, you can export the labelling points by adding SHPT=POINTS
in the Layer
field, ignoring again the error messages. Load both shapefiles into QGIS manually, label the point file with the Text
field, and set the point symbol to zero size.
Best Answer
You can try loading the dxf into QGIS with
Add vector layer
, and then rightclick on the layer andSave As ...
into shapefile format.That way you might get better error messages, and a visual control on the data.
For the shapefile, you must decide what coordinate refrenece system you are using (lat/long degrees or metres).