Skip to main content
Question

Python Caller for two Feature class

  • January 21, 2019
  • 8 replies
  • 171 views

Forum|alt.badge.img

Hello.

I am very new to python and need some help. I am trying to snap a polygon file to Polyline. I have two Feature class which I want to use in Python caller. And there in the transformer, I want to copy a python script which is exported from the model builder in ArcGIS. Can I use one transformer Python caller for both feature class? And also can I copy the script as it is in the python script window of Python caller.

8 replies

david_r
Celebrity
  • January 21, 2019

The PythonCaller can only process a single feature at a time. If you need to process more than one feature, you can e.g. use a FeatureMerger first to assemble a single feature with all the necessary information before sending it to the PythonCaller.

Also, you need to wrap the code in either a function or a class instance, see

https://knowledge.safe.com/articles/60319/pythoncaller-transformer.html


Forum|alt.badge.img
  • Author
  • January 22, 2019

Hi @david_r. Thanks for the reply. But since I am totally unaware of how python script works. I am not able to execute what you are saying. I thought i just need to join two feature class and copy the script from arcpy. Is there any possibility of elaborating the answer if you are aware of Snap_edit function in ArcGIS.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • January 22, 2019

@david_r

 

..erhmm

the link you posted quickly reveals that "..process one feature at a time or a class where you may want to do things to groups of features. The PythonCaller.."

 

 


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • January 22, 2019

You could use the SnappingFactory in a Pythoncaller. (not licensed for base edition I read here..)

and be done with arcpy.


david_r
Celebrity
  • January 22, 2019
gio wrote:

@david_r

 

..erhmm

the link you posted quickly reveals that "..process one feature at a time or a class where you may want to do things to groups of features. The PythonCaller.."

 

 

I think the keyword here is the first few words of the post: "I am very new to python" ;-)

But yeah, anything's possible with Python.


david_r
Celebrity
  • January 22, 2019
gio wrote:

You could use the SnappingFactory in a Pythoncaller. (not licensed for base edition I read here..)

and be done with arcpy.

Or just simply skip Python altoghether and use the Snapper / AnchoredSnapper.


david_r
Celebrity
  • January 22, 2019

As I responded to @gio, is there a particular reason for using Python / arcpy at all here? Have you considered using the Snapper (or AnchoredSnapper) transformers in FME?


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • January 23, 2019
david_r wrote:

As I responded to @gio, is there a particular reason for using Python / arcpy at all here? Have you considered using the Snapper (or AnchoredSnapper) transformers in FME?

I agree with @david_r regarding use of python. (Apart form the fact that I prefer tcl).

 

Personally I always try to solve problems using transformers, keeping snakes and tools at bay.

 

But I also answered the question in which @mukhtar_gf seems intent on using python.

But yeah do you need to?

Obviously not, so I'd go with David's advise and go pure transformers (unless you want to learn python and fme objects etc. in the process)

 


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