CONNECT. TRANSFORM. AUTOMATE.
Beyond 49x Transformers: Don't be afraid
of (the) Python!
Tino Miegel
Software Engineer
Introduction
!  Employed at con terra GmbH
since 2009
!  Spatial ETL Professional
Services
!  FME Certified Trainer since
...
What is Python?
Python is an interpreted, object-oriented, high-level
programming language with dynamic semantics. Its hig...
What is Python?
!  Interpreted language
!  With dynamic typing
!  Extensive standard library
!  Available without charge f...
Why use Python?
!  Easy to learn
!  Very „googlable“
!  Thousands of additional libraries available
!  Fast
!  Comprehensi...
Hello World in Python
#HelloWorld.py
print("Hello World!")
>>>
Hello World!
>>>
Where to find Python in FME
!  Startup and Shutdown
Python Script
" Navigator -> Workspace
Parameters -> Advanced
Demo 1 – Log Statistics
Live Demo
!  Use a Shutdown Python Script to log statistic
information into a central file or data...
Where to find Python in FME
!  PythonCreator and PythonCaller transformers
" QuickAdd or Transformer Gallery
Demo 2 – Handle Dynamic
Attributes
!  Handle features with an arbitrary number of
attributes
!  Leave features with a defi...
Where to find Python in FME
!  Scripted Python Parameter
!  Navigator -> User Parameters -> Private
Parameters
!  Has to e...
Change Default Interpreter
!  Python Options (Custom Interpreter)
" Tools -> FME Options -> Runtime
!  Why?
!  Need other ...
Order of Evaluation
1.  Scripted Python Parameter
2.  Startup Python Script
3.  Workspace logic
1.  Reader
2.  Transformer...
Advanced Usage - FMEObjects
!  Make sure to select
„Install FME SDK“ on
installation of FME
!  API documentation
!  <FMEHO...
Demo 3: WorkspaceRunner
!  Use the Python WorkspaceRunner interface to run
your FME workspaces:
!  run(workspace)	
  
!  w...
Advanced Usage – Plugin SDK
!  Code your own native transformer with Python
!  API documentation
!  <FMEHOME>pluginbuilder...
Thank You!
!  Questions?
!  For more information:
!  Tino Miegel, t.miegel@conterra.de
@TMiegel
!  con terra GmbH, fme@con...
Upcoming SlideShare
Loading in …5
×

Beyond 49x Transformers: Don't be afraid of (the) Python!

1,168 views

Published on

This session gives a short introduction for the usage of Python scripts in FME Desktop processes. First it will be demonstrated how to compute buildings’ roof heights at certain ground points with the PythonCaller and an external Python package. The second demo shows how to persist the FME logfile and the runtime statistics into a central database via Python shutdown script for all those who do not have a FME Server at hand (for now).
See more presentations and videos at: www.safe.com/fmeuc

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,168
On SlideShare
0
From Embeds
0
Number of Embeds
301
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Beyond 49x Transformers: Don't be afraid of (the) Python!

  1. 1. CONNECT. TRANSFORM. AUTOMATE. Beyond 49x Transformers: Don't be afraid of (the) Python! Tino Miegel Software Engineer
  2. 2. Introduction !  Employed at con terra GmbH since 2009 !  Spatial ETL Professional Services !  FME Certified Trainer since 2010 !  FME Certified Professional since 2013 CONNECT. TRANSFORM. AUTOMATE.
  3. 3. What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built in data structures, combined with dynamic typing and dynamic binding, make it very attractive for Rapid Application Development, as well as for use as a scripting or glue language to connect existing components together. Python's simple, easy to learn syntax emphasizes readability and therefore reduces the cost of program maintenance. Python supports modules and packages, which encourages program modularity and code reuse. The Python interpreter and the extensive standard library are available in source or binary form without charge for all major platforms, and can be freely distributed. Source: https://www.python.org/doc/essays/blurb/
  4. 4. What is Python? !  Interpreted language !  With dynamic typing !  Extensive standard library !  Available without charge for all major platforms !  Freely distributable Included in every FME Desktop and FME Server
  5. 5. Why use Python? !  Easy to learn !  Very „googlable“ !  Thousands of additional libraries available !  Fast !  Comprehensive usage e.g. !  Esri ArcGIS !  Blender
  6. 6. Hello World in Python #HelloWorld.py print("Hello World!") >>> Hello World! >>>
  7. 7. Where to find Python in FME !  Startup and Shutdown Python Script " Navigator -> Workspace Parameters -> Advanced
  8. 8. Demo 1 – Log Statistics Live Demo !  Use a Shutdown Python Script to log statistic information into a central file or database !  Access several FME runtime variables via the fme module:  import  fme    runtime  =  fme.elapsedRunTime    >>>    12.3  
  9. 9. Where to find Python in FME !  PythonCreator and PythonCaller transformers " QuickAdd or Transformer Gallery
  10. 10. Demo 2 – Handle Dynamic Attributes !  Handle features with an arbitrary number of attributes !  Leave features with a defined attribute set !  Name !  ID !  Create Attribute Container Features for each attribute with !  referenceFID !  AttributName !  AttributValue Live Demo
  11. 11. Where to find Python in FME !  Scripted Python Parameter !  Navigator -> User Parameters -> Private Parameters !  Has to end with a return statement
  12. 12. Change Default Interpreter !  Python Options (Custom Interpreter) " Tools -> FME Options -> Runtime !  Why? !  Need other python version <2.7 !  Utilize external python packages from a different interpreter, e.g. arcpy
  13. 13. Order of Evaluation 1.  Scripted Python Parameter 2.  Startup Python Script 3.  Workspace logic 1.  Reader 2.  Transformer chain 3.  Writer 4.  Shutdown Python Script
  14. 14. Advanced Usage - FMEObjects !  Make sure to select „Install FME SDK“ on installation of FME !  API documentation !  <FMEHOME>fmeobjects pythonapidoc
  15. 15. Demo 3: WorkspaceRunner !  Use the Python WorkspaceRunner interface to run your FME workspaces: !  run(workspace)   !  withParameters(workspace, parameters) !  promptRun(workspace) Live Demo
  16. 16. Advanced Usage – Plugin SDK !  Code your own native transformer with Python !  API documentation !  <FMEHOME>pluginbuilderpythonapidoc !  Sample (available in FME 2015 Beta builds) !  <FMEHOME>pluginbuildersamplespython
  17. 17. Thank You! !  Questions? !  For more information: !  Tino Miegel, t.miegel@conterra.de @TMiegel !  con terra GmbH, fme@conterra.de !  Python and FME Basics http://fmepedia.safe.com/articles/How_To/Python- and-FME-Basics CONNECT. TRANSFORM. AUTOMATE.

×