1

I built up a polygon layer from a road network for finding roundabouts using the compactness factor of a polygon. Then I have to intersect the extracted roundabout polygons with the road network so that I can find the composing links. This process can take ages to be done using for-loops for each roundabout and intersecting it with all links.

I am wondering if there is a way that I can add the composing links' ID to polygon in the very first step with out intersecting them.

Current algorithm takes three following steps:

  1. FeatureToPolygon function in ArcPy to create the polygons.
  2. Iterating over each polygon and computing the compactness,
  3. And if it's over the threshold then select links which "SHARE_A_LINE_SEGMENT_WITH" the possible roundabout (the polygon in hand with compactness higher than threshold).

The dataset has more than 250000 line features but the number of detected roundabouts are depending on the threshold. it should not be more than 1000.

There is an optional argument about attributes. The ArcGIS (or ArcPy) instruction says not to use it though.


I tried the following code but I get an error.

polyoutputaddress = outputaddress+output_polygon_name
arcpy.FeatureToPolygon_management(inputaddress,polyoutputaddress,"", "NO_ATTRIBUTES", "")

targetFeatures = polyoutputaddress
joinFeatures = inputaddress

outfc = outputaddress+"fieldmapping"+output_polygon_name

fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable(targetFeatures)
fieldmappings.addTable(joinFeatures)

inputFIDIndex = fieldmappings.findFieldMapIndex("JOIN_FID")
inputfieldmap = fieldmappings.getFieldMap(inputFIDIndex)
inputfieldmap
print inputFIDIndex

inputfieldmap.mergeRule = 'Join'
inputfieldmap.joinDelimiter = ','
fieldmappings.replaceFieldMap(inputFIDIndex, inputfieldmap)


arcpy.SpatialJoin_analysis(targetFeatures, joinFeatures, outfc, "#", "#", fieldmappings,"SHARE_A_LINE_SEGMENT_WITH")

here is the error: arcgisscripting.ExecuteError: ERROR 001156: Failed on input OID 0, could not write value '-1,-1,-1' to output field JOIN_FID Failed to execute (SpatialJoin).

as I checked this is because the FID field is numeric, but Join rule should be used for text values.

Any work around this problem?

  • Can you use Spatial Join to stamp the IDs into the polygons? – detroit_hc Oct 20 '14 at 15:50
  • I am already using it. I want not to use it :D – msc87 Oct 20 '14 at 16:01
  • Sorry, it wasn't clear from your question that you were using Spatial Join already. – detroit_hc Oct 20 '14 at 16:03
  • Not exactly spatial join but using Selection by Location. I need to make my code more efficient, so I am checking your solution. Can we concatenate the FIDs of links to one attribute when they "SHARE_A_LINE_SEGMENT_WITH" the polygon? if it can be done could be my solution. – msc87 Oct 20 '14 at 16:07
  • 1
    Perhaps you can clarify in your post the steps you have already taken. Also, how many features are you working with? – Aaron Oct 20 '14 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.