Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a set of features of type linestring. I'm trying to polygonise the linestrings and assumed that they were closed (naive me :) ). Of course some were not closed and I'm trying to locate the gaps or the endpoints of the individual linestrings, so I can close them manually.

How can I locate the gap in or endpoints of an open linestring?

Available software: QGIS, FME, OpenJump, (ArcMap).

share|improve this question
I found that the Sextante toolbox in OpenJump has the Extract endports of lines method. It does the trick, but OpenJump runs out of memory all the time, which is very annoying. I remember something about QGIS having the Sextante toolbox, but I could not find it. – Chau Feb 6 '13 at 16:03
(FME solution) Do you create polygon from one linestring or group of linetrings ? If from one then use Coordinate Extractor from index -1 and 0 then create line from it and pass original and new line to creator, if from group of linestring use linejoiner and use first method to created linestring. – simplexio Sep 15 '13 at 9:12

I used the "Multipart to singlepart"-tool and then selected each feature in the attributes table to find the gap.

share|improve this answer
I think the OP wants some kind of algorithm (the tags indicate it) and not "how-to" steps – Curlew Sep 14 '13 at 21:14

You can identify lines with gaps between endpoints using arcpy Geometry objects (v10.1+). The following returns the distance between endpoints:

with arcpy.da.SearchCursor("LINES_FC", "SHAPE@") as cursor:
    for row in cursor:
        print arcpy.PointGeometry(row[0].firstPoint).distanceTo(arcpy.PointGeometry(row[0].lastPoint))

Of course, additional code may be used to select, zoom to, close, etc. those lines identified as not closed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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