Wednesday, 15 March 2017

arcgis 10.0 - Python script/Model to populate cross street names at intersections



Has anyone created a Python version/model of this VBA script from ArcScripts which populates the to and from street names at street intersections? A logical workflow is outlined quite nicely in this ESRI thread, but it requires ArcInfo, and I would like to know if there is another way to do it.


The end result would be, for example, if there are lines intersecting at First Street and Third Street, and First Street and Main Street, the record for First Street would have to = Third Street and from = Main Street (the order does not matter).


Using Select By Location to select connected roads seems like it would work, and could even possibly replace the need to create points in the aforementioned workflow (looping over each street, writing to separate fields the streets it touches based on the output of the select by location, then extracting the two street names which are different). Does anyone have any other ideas?



Answer



I implemented the workflow above by creating a main model and a submodel. Main model Steps:



  1. Add fields TO_ROAD and FROM_ROAD

  2. Spatial Join with the streets layer as the target and join features. The join operation is one_to_many and the match option is boundary_touches to ensure that all streets touching a single street are joined to that street.


The output of the spatial join and the streets feature class is used as the inputs for the submodel. Submodel




  1. Iterate Feature Selection groups the features according to each unique street_id.

  2. A list (multivalue) of the all the street names joined to the selected features is created.

  3. The street name of the currently selected feature is removed from the list, and the remaining names are written to the two fields added in the main model. If only one street name is found to be touching, "Cul de sac" is written to TO_ROAD.


This solution is not optimised - I needed something quickly to solve my problem. All the processing for the touching streets in the submodel can be put into a single script, but I prefer doing the process visually in ModelBuilder so that I can see my workflow clearly before changing it to Python scripts.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...