I'd like to find out if there is a way to select all of the polyline intersections within one shapefile. The lines are a road network. I've looked through the posts, and the only tip I can find is the intersections tool. That requires two layers, though.

Thanks, Ward

1 Answer 1


In a spatial database such as Spatialite you can do this easily. Polyline intersections are points, so import your roads network into spatialite, and create a new points spatial table:

.loadshp roads_network roads LATIN1 <SRID>
SELECT AddGeometryColumn('intersections','Geometry',<SRID>,'POINT','XY');

The <SRID> parameter is the EPSG code of your coordinate reference system. Now run a query such as (assuming the roads table has a PRIMARY KEY column pk_uid):

INSERT INTO intersections (Geometry) 
SELECT ST_Intersection(r1.Geometry, r2.Geometry) 
FROM roads AS r1, roads AS r2
WHERE r1.pk_uid <> r2.pk_uid;

The WHERE clause insures that you are ignoring the cases of a road intersecting itself.

  • Sweet. I guess I'll try to figure out Spatialite. Thanks- Ward
    – user9492
    Aug 12, 2012 at 20:51
  • This worked very well, once I figured out how to install spatialite (gui. I know.). Thanks again, Ward
    – user9492
    Aug 14, 2012 at 4:45

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.