[GIS] Creating set of equally spaced points along line using QChainage and exporting these as latitude and longitude coordinates in degrees

qchainageqgis

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

Best Answer

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.

Related Question