Question

Python Caller for two Feature class

  • 21 January 2019
  • 8 replies
  • 31 views

Badge

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

Userlevel 4

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

Badge

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.

Badge +3

@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.."

 

 

Badge +3

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

and be done with arcpy.

Userlevel 4

@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.

Userlevel 4

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.

Userlevel 4

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?

Badge +3

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)

 

Reply