I'm facing a problem with a process which should be straight forward, namely transforming a bunch of lines sharing their end nodes to a polygon.
The thing is, it just does not work. I tried a dozen of methods, went through validation and cleaning steps to make sure the data is OK, read dozens of online contributions, tried them all, and so on and so on, but there seems to be something intrinsically wrong with the data that makes it impossible to fulfill this simple task.
I could describe all the variations I went through, but I decided to share the shapefile for whoever is available to check what the problem with the data is.
You'll find it here
I would be very pleased to learn from you, what the clou is. Even some colleagues with many years of experience with QGIS and GIS in general were not able to find the problem.
So, since I have been asked to be more specific with my problems, here it goes.
History I digitalized several features of satellite images using a 'line' layer. Since these features represent the border of management units and I want to transform the layer to a polygon layer, I made sure, that the last node of all lines coincide with the first node of the next line.
I will call it START_LAYER from now on.
My goal: Transform these lines into a polygon.
So, that simple tasks turns out to be impossible, and I do not understand why.
So, what did I do?
Vector > Geometry tools > Lines to polygons
I thought, Ok, sure, I have all individual lines, sure it will not work, so I went over to...
... where I marked all lines (attributes) and merged them using the Merge selected features tool.
I end up with one attribute (I'll refer to it as LAYER_2) Go back to Var. 1 and create the polygon. The result looked like the first one, but the result was different (two different colors in the next picture). Any how, it was not what I was looking for.
Ok, it has to work in a different way.
I went to to do the Geometry Check (tried different parameters, the result might be different, but the following problematic seems to be the same) and tested it on LAYER_2.
Ok, 1) duplicate nodes, that makes sense, since each original line contributes with a node in the intersection point (just strange, having 213 initial lines, why only 51 double nodes?) and 2) Error = Geometry type (MultiLineString) - what ever that means (I still did not understand it).
OK, first get rid of the double nodes. Using the automated fix works for some, but not all.
Mmm, ok, so I'll just do it manually, which however is not really possible, since I just have one attribute.
But well, if I address then the second error "Geometry type (MultiLineString)" by running the proposed solution, several attributes are recreated, funny enough, more than I had initially. (apparently new double nodes appear which did not exist before)
Now I go and remove the double nodes by hand. (LAYER_3)
Go through Var. 1. and Var. 2. > nothing new.
Variant 4: Take all the variants attempted until now an play around with the function Merge Lines available in the menu point Vector. THe result, nothing new.
Note: By the way, I also cleaned my layer also via Check validation, but in the meantime it is clear, that the result has nothing to do with double nodes or similar stuff.
I did try to recreate the process which lead me to the START_LAYER, i.e. creating lines with common end nodes and then I apply Polygonize and it works perfectly. Not with the START_LAYER.
Variant 6: Something drastic:
and then use the plugin
to generate the polygon form the points.
I try it only for one segment
I tried the plug-in for a data freshly created first lines, then node extraction, then polygon creation with the Points2One plug-in and it works fine.
It is as if some intrinsic value of the nodes is messing up every step I try. Some time-stamp, etc. I do not know, I really do not understand the system in depth.
I did try other stuff, which I will not explain now , I think the point is more than clear, probably I was redundant with some explanations.
What I really want to use is the Polygonize which normally works sooo well with fresh data.
So that is why I shared the data so you can try to understand what is wrong (or what I AM doing wrong) with it.
The full data set can be downloaded here:. This line shapefile should be free of double nodes or some other type of error according to the validation functions in QGIS.