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'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

share|improve this question

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.

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

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.