Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Recursive Python Function

$
0
0
So I have no clue how to do this but I'm 99% positive it's possible...I think.

I need to execute a function against every single feature in a feature class, but in a sequential and recursive manner. So let's say I'm creating a network value for each feature. The network value for each feature depends on the value of other items in the network. So every time the network value for a feature is calculated, all previously calculated values must be recalculated in order to account for the value of the newly calculated feature's network value.

So, let's say I have a feature class

FeatureClass
ID Shape Name Network Value
1 Point Feature1 <Null>
2 Point Feature2

<Null>

3 Point Feature3

<Null>

4 Point Feature4

<Null>

5 Point Feature5

<Null>




I want to calculate the value for Feature1.
ID Shape Name Network Value
1 Point Feature1 100
2 Point Feature2

<Null>

3 Point Feature3

<Null>

4 Point Feature4

<Null>

5 Point Feature5

<Null>





Then I want to calculate the value for Feature2.
ID Shape Name Network Value
1 Point Feature1 100
2 Point Feature2

93

3 Point Feature3

<Null>

4 Point Feature4

<Null>

5 Point Feature5

<Null>




But now there are multiple items in the network which means that now Feature1's network value is possibly incorrect, so Feature1 has to be recalculated..
ID Shape Name Network Value
1 Point Feature1 98
2 Point Feature2

93

3 Point Feature3

<Null>

4 Point Feature4

<Null>

5 Point Feature5

<Null>




Now calculate the network value for Feature3, then recalculate Feature2, then recalculate Feature1
ID Shape Name Network Value
1 Point Feature1 92
2 Point Feature2

88

3 Point Feature3

76

4 Point Feature4

<Null>

5 Point Feature5

<Null>


So on and so forth until I've calculated a network value for Feature5 and recalculated the values for features 1-4

Then stop the iteration.

any help or info is appreciated...

Viewing all articles
Browse latest Browse all 2485

Trending Articles