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. Steps:
- Add fields
TO_ROAD
andFROM_ROAD
Spatial Join
with the streets layer as the target and join features. The join operation isone_to_many
and the match option isboundary_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.
Iterate Feature Selection
groups the features according to each uniquestreet_id
.- A list (multivalue) of the all the street names joined to the selected features is created.
- 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