Skip to main content
I tr to execute the following arcpy function from a fme workbench:

 

 

arcpy.CalculatePolygonMainAngle_cartography("FeatureLayer", "poly_angle")

 

 

from the PythonCaller transformer to calculate a polygons main angle. What I can't really understand (as my python skills are absolute nonexisting) is how to wrap than inside the template function interface. I have tried to integrate the arcpy- function like this:

 

 

---

 

import fmeobjects

 

import arcpy

 

 

def angleFeature(feature):

 

    ang = arcpy.CalculatePolygonMainAngle_cartography("FeatureLayer", "angle")

 

    feature.setAttribute("angle", ang)

 

--

 

 

but when trying to run the workbench I get the following error

 

 

ERROR 000732: Input Features: Dataset FeatureLayer does not exist or is not supported

 

 

so Im stuck with the problem that the function cant find my source (wich is a Geodatabase_SDE reader. It also feels that once I get the features into the function, CalculatePolygonMainAngle will write the angle to the attribute "angle" and then fme will write it once again in feature.setAttribute.

 

 

I obviously dont know much python, perhaps someone else knows and might help out?
Hi,

 

 

Cant help you much about the python, there are better experts for that in the community, but I can provide you with the FME solution: the PolylineAnalyzer transformer from the FME Store.

 

 

Hope this helps,

 

Itay

 


Itay, I have thought about that transformer but couldn't find a way to use it as I couldnt find much . The ArcPy function calculates the "longest collection of segementsthat have similar orientation" The PolylineAnalyzer documentation is a little sparse, do you have any idea on how to use it instead?
Hi,

 

 

If I understand the definition correctly it would be a matter of testing the objects resulting from the PolylineAnalyzer for the object with the maximal lenght in the same azimuth/angle category.

 

All of these attributes are gathered by the transformer.

 

You can also test your FME results with the results of the script in the ESRI environment.

 

 

Itay

Reply