Although there is already an accepted answer to this question, as it was tagged as arcpy, I'd like to add one open source alternative by using one equivalent tool: PyQGIS.
My polyline layer was very similar to above question:
Complete code is:
import itertools
layer = iface.activeLayer()
feats = [ feat for feat in layer.getFeatures() ]
n = len(feats)
list = range(n)
points = [ feats[i].geometry().intersection(feats[j].geometry()).asPoint()
for i,j in itertools.combinations(list, 2)
if feats[i].geometry().intersects(feats[j].geometry()) ]
lines = [ [ points[i], points[j] ]
for i,j in itertools.combinations(list, 2) ]
epsg = layer.crs().postgisSrid()
uri = "Point?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes"
mem_layer = QgsVectorLayer(uri,
'points',
'memory')
prov = mem_layer.dataProvider()
feats = [ QgsFeature() for i in range(len(points)) ]
for i, feat in enumerate(feats):
feat.setAttributes([i])
feat.setGeometry(QgsGeometry.fromPoint(points[i]))
prov.addFeatures(feats)
QgsMapLayerRegistry.instance().addMapLayer(mem_layer)
uri = "LineString?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes"
mem_layer = QgsVectorLayer(uri,
'lines',
'memory')
prov = mem_layer.dataProvider()
feats = [ QgsFeature() for i in range(len(lines)) ]
for i, feat in enumerate(feats):
feat.setAttributes([i])
feat.setGeometry(QgsGeometry.fromPolyline(lines[i]))
prov.addFeatures(feats)
QgsMapLayerRegistry.instance().addMapLayer(mem_layer)
After running it at the Python Console of QGIS, I got crossing points and split polyline layer: