There was a time, not too long ago, when scripting GIS software required learning specialized languages that were not only vendor-specific, but also not used outside of the industry. This made scripts into islands that could not talk to other another vendor’s environment, and limited the pool of people working in the language to a small group of GIS professionals. Today, many vendors (as well as most open source GIS tools) have some form of Python support, which not only allows scripts to not talk to multiple vendors, but also to take advantage of thousands of free libraries written by Python programmers who don’t use GIS.

Perhaps the most flexible of FME’s 300+ transformers is the PythonCaller. While consisting of only 2 parameters (Python symbol and Python source), it opens up workspaces to talk to any python library, which can be very powerful. In the past, we required users to install Python on their systems independently of FME in order to use these transformers, however recently we began bundling a Python interpreter with FME, which has opened up the use of this transformer to even more users.

A common task for the PythonCaller is to push features from FME into another program, and then pull them back in. For example, if you need to geocode tabular data before processing it with FME, you can easily pass it to an ESRI python geoprocessing script, or any other python library for that matter. Python is also a great way to interact with webservices which FME cannot natively read or write from, such as Google Spreadsheets. We are aware of several cases where people have used Python to access ESRI’s Geoprocessing tools in workspaces to perform tasks specific to ESRI tools.fmepython_medium

In addition to allowing you to use external Python libraries in FME, we also have our own Python library, pyfme, which exposes our FME Objects API in Python. With this, you can actually create your own transformers in Python, such as a geocoder.

There are some great resources out there on using Python in GIS applications. Oliver’s Python Corner is probably the best source for FME-specific Python information. Oliver’s tutorial and sample code is great way to get up and running with Python in your workspaces. Sean Gillies (maintainer of some wonderful open source GIS Python libraries) has a blog where he often posts useful Python snippets (his recent Python and GIS 101, while somewhat abstract, is a great introduction of using Python for GIS. Hopefully the “101” means this is the beginning of a series). ESRI has a large library of Python Geoprocessing scripts which can be plugged into FME with a little work. Lastly, Sean Gillies has started a Python GIS SIG Google Group, which has some great discussion of general GIS/Python issues.

With so many GIS platforms offering Python support, it has become very easy to create unified workflows which pull from several libraries. By having the industry largely standardized on a powerful, non domain-specific programming language with very wide usage outside the GIS community, we now have a larger community to both share our own work with, as well as borrow from to make our own scripts better.

About Data General Interoperability Spatial Data Interoperability

Michael Weisman

Comments

11 Responses to “Snakes on a Map: Python in GIS”

  1. […] This post was mentioned on Twitter by ManoMarks, Jeffrey Barke and Francesco Ciriaci, jeremiahakin. jeremiahakin said: RT @ManoMarks: I just love the title of this post: Snakes on a Map: Python in GIS http://bit.ly/mOe38 […]

  2. […] Snakes on a Map: Python in GIS […]

  3. Social comments and analytics for this post…

    This post was mentioned on Twitter by ManoMarks: I just love the title of this post: Snakes on a Map: Python in GIS http://bit.ly/mOe38

  4. Sean Gillies says:

    Michael, I appreciate the mention. “How to plug in” is a one of the themes of the unofficial Python GIS SIG.

  5. I have been following the Python GIS SIG since you first tweeted about it. I would happy to assist people with plugging into FME, or any other GIS environment!

  6. […] what I have to say in this post isn’t particularly original or unique. Others have said it […]

  7. […] was not suitable for all programming tasks. Indeed the number of languages continues to grow with Python being just one example of another popular and growing […]

  8. Ayman Hamzeh says:

    Hi;

    Could you please send me a good example as python script about how if I need to geocode tabular data before processing it with FME, to pass it to an ESRI python geoprocessing script?

    I need to create Geocoders with specific parameters using Python and FME. Could you please help me?

    Thank you

    Ayman

  9. Hi Ayman,

    What Geocoding service are you going to be using? If it has a web interface, you may be able to use FME’s HTTPFetcher transformer instead of Python.

    If you have a limited number of points to geocode, you can use Google Earth’s built-in geocoding. Please see “http://fmepedia.safe.com/articles/How_To/How-to-use-Google-Earth-to-Georeference-KML-files” for more information.

    Regards,

    Dave Campanas

  10. John Zhang says:

    Hey there,

    Did anyone point me to where I can get samples for data translation, ie using python readers and writers to read and write data in desired formats?

    Thank you very much in advance.

    John Zhang

  11. […] Snakes on a Map: Python in GIS – Safe Software Blog – Hi Ayman, What Geocoding service are you going to be using? If it has a web interface, you may be able to use FME’s HTTPFetcher transformer instead of Python…. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts