Created
April 20, 2016 20:01
-
-
Save AlexArcPy/6955a89c259e76b19bcacced2eb519d0 to your computer and use it in GitHub Desktop.
Call FME workbench from Python: FMEWorkspaceRunner and dynamic workspace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
sys.path.append(r"C:\Program Files (x86)\FME\fmeobjects\python27") | |
import fmeobjects | |
#---------------------------------------------------------------------- | |
def project_multiple_shapefiles(): | |
"""Finds all shapefiles in the input folder, projects and outputs | |
a projected feature type into output folder.""" | |
try: | |
wkspc_path = r"C:\GIS\fme\FMEWorkbenches\DynamicWorkspace.fmw" | |
wkspc = fmeobjects.FMEWorkspaceRunner() | |
data_folder = r"C:\GIS\fme\Data" | |
for shp in [shp_file for shp_file in os.listdir(data_folder) | |
if shp_file[-4:] == '.shp']: | |
parameters = {} | |
parameters["Src"] = os.path.join(data_folder,shp) | |
parameters["Dest"] = r"C:\GIS\fme\out" | |
parameters["SRID"] = r"EPSG:3857" | |
wkspc.runWithParameters(wkspc_path,parameters) | |
except fmeobjects.FMEException, err: | |
print "FMEException: %s" % err | |
sys.exit(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment