I have thousands of vectors (out of several million) which I need to flip, for directionally purposes (Network Analyst).

The vectors in question are annotated that their directionality has been reversed.

Anyone have or know of a way to flip multiple vectors at once or have any code which would do the same?

  • 2
    Do you mean transpose? – John Powell Oct 19 '14 at 13:45
  • 1
    And are you using numpy? In numpy it is simply a.T, where a is some matrix. You can return this to a normal python list with tolist, or just a.T.tolist(). It would also be easy to write a double loop and just reverse the indexes for the transposed array. – John Powell Oct 19 '14 at 13:59

there is a flipline tool, though it doesn't seem to allow queries on a feature. it may be that you can provide the tool with a feature layer based on the selected attributes.

EDIT: As @JasonT mentioned, the flip tool should honor selections, so perhaps use make feature layer with a SQL clause on the features that should be flipped and pass that layer to flipline.

from the link above:

import arcpy
from arcpy import env
except Exception, e:
     # If an error occurred, print line number and error message
    import traceback, sys
    tb = sys.exc_info()[2]
    print "Line %i" % tb.tb_lineno
    print e.message
  • The flip tool honors selections or definition query, so just apply one or the other to the data 1st. (It will only flip those that are selected). If it is a large dataset, my favorite is the definition query, b/c it is faster. – JasonT Oct 19 '14 at 17:16
  • John/Jason - Thank you. I meant flipping a line vector (resources.arcgis.com/en/help/main/10.1/index.html#//…). Jason I thin the flipline tool will work. I believe I can modify that code for my needs - Thank you both – Jeff Oct 20 '14 at 2:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.