Question

Is possible to access adjacent features (similar to AttributeManager adjacent features) using PythonCaller?

  • 21 August 2017
  • 2 replies
  • 1 view

Badge

I was thinking in something similar to feature[+1].

Is this possible?


2 replies

Badge +22

As far as I am aware the python function does not have this ability, but you can create it using the class.  Note that you'll want to catch the first and last elements of the lists to avoid an index out of range exception (first feature has no previous, last feature has no next)

class FeatureProcessor(object):
    def __init__(self):
        self.featureList=[]
    def input(self,feature):
        self.featureList.append(feature)
    def close(self):
        for i, feat in enumerate(self.featureList):
            previous = self.featureList[i-1]
            next = self.featureList[i+1]
Badge

As far as I am aware the python function does not have this ability, but you can create it using the class.  Note that you'll want to catch the first and last elements of the lists to avoid an index out of range exception (first feature has no previous, last feature has no next)

class FeatureProcessor(object):
    def __init__(self):
        self.featureList=[]
    def input(self,feature):
        self.featureList.append(feature)
    def close(self):
        for i, feat in enumerate(self.featureList):
            previous = self.featureList[i-1]
            next = self.featureList[i+1]
Many thanks!

Reply