Skip to main content

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

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


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 = s929437, 929438, 929441, 929442, 929443, 929444]
        ycoords = 10,1,2,3,4,5]
        coords = list(zip(xcoords,ycoords))
        newFeature = fmeobjects.FMEFeature()
        newFeature.addCoordinates(coords)
        self.pyoutput(newFeature)
    def close(self):
        pass

 


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.


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 = s929437, 929438, 929441, 929442, 929443, 929444]
        ycoords = 10,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


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 = <929437, 929438, 929441, 929442, 929443, 929444]
        ycoords = >0,1,2,3,4,5]
        coords = list(zip(xcoords,ycoords))
        feature.removeGeometry()
        feature.addCoordinates(coords)

 this may be more suitable


Reply