Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

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>
CREATE TABLE intersections (pk_uid INTEGER PRIMARY KEY AUTOINCREMENT)
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

 
discard

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.