Skip to main content
Question

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


Forum|alt.badge.img

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

Is this possible?

2 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • August 21, 2017

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]

Forum|alt.badge.img
  • Author
  • August 22, 2017
jdh wrote:

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!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings