Skip to main content
Solved

Fme creating a whole new set of points features from another


Forum|alt.badge.img+1

Hello,

I have a problem of optimization. I have a very large set of points with arguments that I can't combine before sorting it. The points are divided themsleves with an argument, and I have around 100-500 points for each group.

The problem being that I want to reduce that number to approximately fifty. The new coordinates for each of these fifty points is computed using the other 500, and an argument that each one has.

So is there a way we can we replace all the vertex in a feature at once, with lists of points ?

The lists would look like this going out of the Python Caller . This is for one coordinate only, the x.

[929437.0060424805, 929441.2712402344, 929441.2976074219, 929441.3193969727, 929442.5599975586, 929444.1078491211]

Any idea on how to proceed, or another approach possible ?

Thanks

Best answer by ebygomm

This is how you could create a feature from a list of points in a python caller

import fme
import fmeobjects
 
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        xcoords = [929437929438929441929442929443929444]
        ycoords = [0,1,2,3,4,5]
        coords = list(zip(xcoords,ycoords))
        newFeature = fmeobjects.FMEFeature()
        newFeature.addCoordinates(coords)
        self.pyoutput(newFeature)
    def close(self):
        pass

 

View original
Did this help you find an answer to your question?

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

What kind of computation do you want to do to reduce the number?


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • Best Answer
  • December 9, 2020

This is how you could create a feature from a list of points in a python caller

import fme
import fmeobjects
 
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        xcoords = [929437929438929441929442929443929444]
        ycoords = [0,1,2,3,4,5]
        coords = list(zip(xcoords,ycoords))
        newFeature = fmeobjects.FMEFeature()
        newFeature.addCoordinates(coords)
        self.pyoutput(newFeature)
    def close(self):
        pass

 


Forum|alt.badge.img+1
  • Author
  • December 9, 2020
redgeographics wrote:

What kind of computation do you want to do to reduce the number?

The computation is a simple Python program. Each line is a certain length, and every point has a length from the first point, following the line, not just a 3D distance . All in 3D, with curved lines.

So I make 50 points that are equidistant, as I can get the total length, and I put them inbetween the other that I have, to get them as close as possible as where they should be, if the line was divided as I wanted. The approximations are good enough, I have checked beforehand.

I can draw it if you want, but ebygomm has an answer close to what I am looking for, thank you.


Forum|alt.badge.img+1
  • Author
  • December 9, 2020
ebygomm wrote:

This is how you could create a feature from a list of points in a python caller

import fme
import fmeobjects
 
class FeatureProcessor(object):
    def __init__(self):
        pass
    def input(self,feature):
        xcoords = [929437929438929441929442929443929444]
        ycoords = [0,1,2,3,4,5]
        coords = list(zip(xcoords,ycoords))
        newFeature = fmeobjects.FMEFeature()
        newFeature.addCoordinates(coords)
        self.pyoutput(newFeature)
    def close(self):
        pass

 

I did not expect FME to simply erase the features that were here before, but thanks a lot for this, it was much more simple than I thought


ebygomm
Influencer
Forum|alt.badge.img+31
  • Influencer
  • December 9, 2020
theodore wrote:

I did not expect FME to simply erase the features that were here before, but thanks a lot for this, it was much more simple than I thought

This is creating a whole new feature, so if there are any other attributes required they won't be kept. An alternative is to remove the existing geometry before replacing, or clone the existing feature and then remove and replace the geometry. A lot depends on your inputs, if your PythonCaller is just doing a 1 in 1 out process something like

import fme
import fmeobjects
 
def processFeature(feature):
        xcoords = [929437929438929441929442929443929444]
        ycoords = [0,1,2,3,4,5]
        coords = list(zip(xcoords,ycoords))
        feature.removeGeometry()
        feature.addCoordinates(coords)

 this may be more suitable


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