0

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.

Strahler

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']
  • Hi, this would help if you shared your GeoJSON file. Right now it is difficult to tell what's wrong in your code. – ArMoraer Nov 24 '20 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.