I am working on a Python project working with a GeoJSON file (Linestring type).
The aim of this project is to classify lines based on Strahler Order (Wikipedia : https://en.wikipedia.org/wiki/Strahler_number). Here below a picture to understand it.
I run a Python script that I wrote to detect OERDER 1 but when I test it on a line that I know it got Order 1, I always get 0. I don't know where is the problem in my code.
Here below my code :
import json
file = open('C:/Users/LENOVO/Desktop/data_with_subgraphs5.json')
data = json.load(file)
def search(data):
featureA = []
featureB = []
for feature in data['features']:
featureA = feature['geometry']['coordinates'][0]
for ftr in data['features']:
featureB = ftr['geometry']['coordinates'][0]
if featureA[0] in featureB or featureA[-1] in featureB :
feature['properties']['Strahler'] = 1
else :
feature['properties']['Strahler'] = 0
return data['features'][372]['properties']