2

In QGIS 2.2.0, how do I create a set of equally spaced points along a line using QChainage and export these as latitude and longitude coordinates in degrees? I am using the QChainage function in QGIS, but it is generating the following error:

An error has occured while executing Python code:

Traceback (most recent call last):
File "/Users/shafiquejamal/.qgis2/python/plugins/qchainage/qchainagedialog.py", line 126, in accept
selectedOnly)
File "/Users/shafiquejamal/.qgis2/python/plugins/qchainage/chainagetool.py", line 92, in points_along_line
features = create_points_at(startpoint, endpoint, distance, geom)
File "/Users/shafiquejamal/.qgis2/python/plugins/qchainage/chainagetool.py", line 43, in create_points_at
feature.setGeometry(point)
TypeError: QgsFeature.setGeometry(QgsGeometry): argument 1 has unexpected type 'NoneType'

I have consulted the following posts, but was unable to solve this issue:

Creating points along lines using QGIS? How can I represent distance using the dashes or markers of a vector line?

  • This post directs me to QChainage, which I am trying to use.

http://nathanw.net/2012/08/05/generating-chainage-distance-nodes-in-qgis/

  • I don't know how to implement this solution; I tried to run the python code but it just produced a blank Canvas. It may be because I failed to select the lines, which I thought is done by making the layer with the line active.

Creating equidistant points in QGIS?

  • Again, I'm not sure how to implement the code in the above post.

Creating points in specified distance along line using QGIS?

  • This recommends Densify, which doesn't seem relevant to what I want to do. SEXTANTE is deprecated, and not available as a plugin in QGIS 2.2.0 (I think its functions are built in to QGIS 2.2.0).

http://wiki.tuflow.com/index.php?title=QGIS_Convert_Lines_to_Points

  • The MMQGIS option can do something similar, but it only gets the nodes; it does not produce equally spaced points.

I know this question has been asked and answered in other posts (most or all of which I think are listed above). The difference with my question is that I am getting this strange error when I try to use QChainage. I was able to use QChainage before and it worked, but now I am using it on layers that I generated by adding a buffer to a line, converting the buffer polygon to a line, and then removing parts of the line (see here: How do I plot a line on a map, or obtain the latitude and longitude coordinates of such a line, that is 120km north of the US-Canada border?). If you look at the line in the image below, you can see that the line is broken (it is several lines). Maybe this is the problem?

enter image description here

I am pasting below a picture of what the line looked like after I added a buffer and converted the polygons to lines, but before deleting parts of the line:

enter image description here

Here is a zoomed in view of the line, showing that it comprises line segments:

enter image description here

3
  • SEXTANTE is now called Processing, so all commands should still be available. For me, QChainage works, but only with spacing up to 9999 metres. I wonder why your buffer line is not closed. Is the layer still in EPSG:5070?
    – AndreJ
    Commented May 6, 2014 at 6:02
  • Hello Andre, yes the layer is still in EPSG:5070. I have added screenshots to show (a) what adding a buffer and then converting polygons to lines did (but before deleting parts of the lines that cross and are south of the US-Canada border) and (b) a zoomed in view of what the line looks like after deleting parts of it. The line comprises line segments. Is the solution to join the line segments? If so, how would I do this? Thanks! Commented May 6, 2014 at 12:08
  • This works - thanks! What I did was use border data from Natural Earth (Admin 0 – Boundary Lines). Perhaps you could move this comment to an answer, so that I can accept it as an answer? Cheers, Commented May 6, 2014 at 14:47

1 Answer 1

1

The lines to buffer should be contiguos.

I usually take the borders from Natural Earth world boundaries, which comes as polygons. The border lines from gadm.org should be closed as well.

I described a workflow to combine lines here: How to visually sort the order of Points with QGIS, GDAL, ...?

Vector -> Geoprocessing -> Dissolve using dissolve all lets you create a single buffer around all segments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.