[GIS] Who uses FME Python extension and how

fmepython

I saw a great interface to FME with Python

What you guys are doing with it? I want ideas.

Best Answer

I'm just getting started with FME, and am using a shutdown script to copy my target FGDB to another location and to save out the log file:

import distutils.dir_util, shutil, os, time, locale

src = 'C:/Testing/FME/TPW/Third_Party_Wells.gdb'
dst = '//share/Data Services/GIS Data/Data/Third Party Wells/Third_Party_Wells.gdb'

distutils.dir_util.copy_tree(src, dst)

logfile = FME_LogFileName
shutil.copy(logfile, 'C:/temp/PRD_' + os.path.basename(logfile)[:-4] + '_' + time.strftime('%Y_%m_%d_%H_%M_%S', time.localtime()) + '.log')

# Get features written counts
shl_count = str(FME_FeaturesWritten['ThirdPartyWellsSurface'])
bhl_count = str(FME_FeaturesWritten['ThirdPartyWellsBottom'])
lat_count = str(FME_FeaturesWritten['ThirdPartyWellsLaterals'])

# Write out features written counts to log
fm_log = open('C:/temp/PRD_Counts.log','a')
fm_log.write(time.strftime('%m/%d/%Y %I:%M:%S', time.localtime()) + ',' + shl_count + ',' + bhl_count + ',' + lat_count + ',' + str(FME_TotalFeaturesWritten) + '\n')

That's pretty basic, but there really is no limit I don't think. There are tons of ideas here as well.

EDIT: Added in code to get numbers of features written and push those out to CSV log file.