Hi everyone,
I have created a custom transformer to generate points using lat/lng using the following simple script. It works totally fine. However, it loses all of the attributes coming from my input file. Is there a way to retain it dynamically?
Hi everyone,
I have created a custom transformer to generate points using lat/lng using the following simple script. It works totally fine. However, it loses all of the attributes coming from my input file. Is there a way to retain it dynamically?
You have created and returned a new FMEFeature instance in the script. FME won't propagate the attributes of the input feature to the new feature automatically.
If you need to preserve all the attributes in the input feature, you don't need to create a new feature.
Just set the geometry and the coordinate system to the input 'feature' and output it.
I agree with @takashi. If, for some reason you really need to create a new copy of the incoming feature, you can replace the line
newFeature = fmeobjects.FMEFeature()
with
newFeature = feature.clone()
This will create a new feature as a clone of the incoming feature.
You have created and returned a new FMEFeature instance in the script. FME won't propagate the attributes of the input feature to the new feature automatically.
If you need to preserve all the attributes in the input feature, you don't need to create a new feature.
Just set the geometry and the coordinate system to the input 'feature' and output it.
Thanks Takashi,
newFeature = fmeobjects.FMEFeature() newFeature.setGeometry(FMEPoint(float(feature.getAttribute('lONGITUDE')), float(feature.getAttribute('lATITUDE'))))
so I am trying the following line instead but getting this error. Do you know why?
FMEFeature.setGeometry(FMEPoint(float(feature.getAttribute('lONGITUDE')), float(feature.getAttribute('lATITUDE'))))
I agree with @takashi. If, for some reason you really need to create a new copy of the incoming feature, you can replace the line
newFeature = fmeobjects.FMEFeature()
with
newFeature = feature.clone()
This will create a new feature as a clone of the incoming feature.
Thanks David for the tip!
You have created and returned a new FMEFeature instance in the script. FME won't propagate the attributes of the input feature to the new feature automatically.
If you need to preserve all the attributes in the input feature, you don't need to create a new feature.
Just set the geometry and the coordinate system to the input 'feature' and output it.
oh it should be feature instead of FMEFeature
It tends to be more straightforward to use the function interface rather than the class interface if you're just doing a one in one out process
import fme
import fmeobjects
def processFeature(feature):
feature.setGeometry(fmeobjects.FMEPoint(float(feature.getAttribute('longitude')), float(feature.getAttribute('latitude'))))
feature.setCoordSys(feature.getAttribute('coord_sys'))
Even easier to just use a vertex creator though :-)