I ran across a need to do this and wrote a script. It only transfers the shape field but could be edited to transfer whatever attributes you want. Set the interval variable to however long you want the output lines to be. Note that there will be a fraction at the end of each line that is less than the interval distance.
<SPAN class="comment token">## splitLinesAtIntervals.py</SPAN> <SPAN class="comment token">## inputs ## </SPAN> interval <SPAN class="operator token">=</SPAN> <SPAN class="number token">50</SPAN> <SPAN class="comment token">## units of inFC projection</SPAN> inFC <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'path\to\inFeatureClass'</SPAN> outFC <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'path\to\outFeatureClass'</SPAN> <SPAN class="comment token">## get to work</SPAN> <SPAN class="keyword token">import</SPAN> arcpy arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN> iCur <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>outFC<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'SHAPE@'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>inFC<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'SHAPE@'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> sCur<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> sCur<SPAN class="punctuation token">:</SPAN> lineLength <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>length position <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> lineGeometry <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">## while length left??</SPAN> <SPAN class="keyword token">while</SPAN> lineLength <SPAN class="operator token">></SPAN> position<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">## position point along line at interval</SPAN> splitPoint <SPAN class="operator token">=</SPAN> lineGeometry<SPAN class="punctuation token">.</SPAN>positionAlongLine<SPAN class="punctuation token">(</SPAN>interval<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">## split line at point</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SplitLineAtPoint_management<SPAN class="punctuation token">(</SPAN>lineGeometry<SPAN class="punctuation token">,</SPAN> splitPoint<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'in_memory/split'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">## insert the split line into outFC</SPAN> <SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'in_memory/split'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'OID@'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'SHAPE@'</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> splitCur<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> splitCur<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">if</SPAN> i<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">==</SPAN> <SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="comment token">## insert row</SPAN> iCur<SPAN class="punctuation token">.</SPAN>insertRow<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>i<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN> lineGeometry <SPAN class="operator token">=</SPAN> i<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> position <SPAN class="operator token">+=</SPAN> interval <SPAN class="keyword token">del</SPAN> iCur<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.