All of my road segments have beginning milepost and ending milepost data. What's the best way to split all of my segments into .25mi pieces and repopulate the new beginning and ending milepost data?
Hi Anthony Von Moos ,
There are a couple of tools out there that will split your line using different methods inside and outside editing sessions, but I don't think it will update your bmp and emp values. See the support page on this topic:
You can script this using the segmentAlongLine function in arcpy. Below an example of the logic:
<SPAN class="keyword token">import</SPAN> arcpy <SPAN class="comment token"># set you split distance</SPAN> split_dist <SPAN class="operator token">=</SPAN> <SPAN class="number token">2.5</SPAN> <SPAN class="comment token"># create a simple line</SPAN> fpnt <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> tpnt <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN><SPAN class="number token">10.5</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN> sr <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">(</SPAN><SPAN class="number token">102100</SPAN><SPAN class="punctuation token">)</SPAN> line <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Polyline<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>Array<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>fpnt<SPAN class="punctuation token">,</SPAN> tpnt<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">,</SPAN> sr<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># split the line</SPAN> dist <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> endprev <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> cnt <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> <SPAN class="keyword token">while</SPAN> dist <SPAN class="operator token"><=</SPAN> line<SPAN class="punctuation token">.</SPAN>length<SPAN class="punctuation token">:</SPAN> cnt <SPAN class="operator token">+=</SPAN> <SPAN class="number token">1</SPAN> bmp <SPAN class="operator token">=</SPAN> endprev linep <SPAN class="operator token">=</SPAN> line<SPAN class="punctuation token">.</SPAN>segmentAlongLine<SPAN class="punctuation token">(</SPAN>dist<SPAN class="punctuation token">,</SPAN> dist <SPAN class="operator token">+</SPAN> split_dist<SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN> emp <SPAN class="operator token">=</SPAN> dist <SPAN class="operator token">+</SPAN> linep<SPAN class="punctuation token">.</SPAN>length <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"line {}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>cnt<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">" - bmp {}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>bmp<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">" - emp {}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>emp<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> endprev <SPAN class="operator token">=</SPAN> emp dist <SPAN class="operator token">+=</SPAN> split_dist<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>
This will print:
line 1 - bmp 0 - emp 2.5 line 2 - bmp 2.5 - emp 5.0 line 3 - bmp 5.0 - emp 7.5 line 4 - bmp 7.5 - emp 10.0 line 5 - bmp 10.0 - emp 10.5<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>
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.