Script for simultaneous looping and dissolve

5563
27
Jump to solution
06-03-2015 09:23 AM
SalmanAhmed
New Contributor III

In the table attached you can see the destination cities in 'Destination' field. Many of them are same - Werne Werne Werne.......

I want to create a script/model such that when run, it loops through all the rows with the same destination city  (all the rows that have Werne for example) and then out of them selects the row that has the maximum value in the 'Commuters' field and then dissolves the destination city with the origin city ('Origin' field) for that row.

For example for Werne the row with the maximum value in the commuter field is the first row. So the tool should identify that and then dissolve Werne with Bergkamen in the map.

And then this should be done for every destination city. So basically the looping must happen only until the rows with same destination cities. Then after dissolving that city with its origin city a new loop should be created for the next destination city in the 'Destination' field.Untitled2.png

0 Kudos
27 Replies
DanPatterson_Retired
MVP Emeritus

Arrows? do you mean on the lines? if that is the case double click on the layer, select symbology and choose one of the line symbols that has arrow head symbology

SalmanAhmed
New Contributor III

Oh why did I not think of that. Thank you so much.

0 Kudos
WesMiller
Regular Contributor III

I think what you are trying to do could be accomplished with the dissolve tool. Check the Destination field in the dissolve fields then In the statistics fields drop down pick the commuters field and it will appear below set the Statistic type to what you want to get (sum of values or max value)

BlakeTerhune
MVP Regular Contributor

I agree, I think a dissolve on the Destination field with statistics for maximum Commuter field sounds like the solution. If you want to keep the original shapes, you could always just join the result back to the original using the Destination field; e.g., all occurrences of Werne would have the same commuter statistic value from the dissolve output table.

ArcGIS Help 10.1 - Dissolve (Data Management)

SalmanAhmed
New Contributor III

Okay will try it and post what happens.

0 Kudos
WesMiller
Regular Contributor III

I don't see Bergkamen in your destination field i see it in your origin field,but not aligned(in the same row with Unna. Do you have a field that you could use that groups your data?

0 Kudos
SalmanAhmed
New Contributor III

Oh Im so sorry I read the names wrong. I was saying Bergkamen for Werne and not Unna. Its just an example. And Bergkamen is there is the destination field further down the table as well. This is not the whole table its just a screenshort. There are around 400 features in total which include each name in the destination field.

0 Kudos
SalmanAhmed
New Contributor III

I do have a field that gives a unique ID to every origin-destination pair. But dont know how that would help to combine polygons.

0 Kudos