Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Wednesday, 4 April 2018

ArcPy in FME

To enable ArcPy in FME:
  1. Make sure you have ArcGIS Desktop Background Geoprocessing (64-bit) and the 64-bit version of FME installed;
  2. In FME, go to Tools > FME Options... > Translation;
  3. Set the Preferred Python Interpreter to C:\Windows\System32\Python32.dll.

After that you can just type in import arcpy in your Python code:




(Note: this solution may work for me because I have ArcGIS Pro installed.)

Tuesday, 27 February 2018

Python: Get Filename and Folder Name

Filename


# Get the full name of the input DWG file
s1 = FME_MacroValues['InputDWG']

# If there is a backslash, take the bit after the last one
if "\\" in s1:
    s2 = s1.split('\\')[-1]

# if the output file is in the same folder as the workbench,
# FME uses a relative folder without slashes: $(FME_MF_DIR)foo.bar
elif "FME_MF_DIR" in s1:
    s2 = s1[13:]

# Chop off the extension
return s2.split('.')[0]

Combine Raster Bands

To combine multiple single-band rasters into a single multi-band raster, use the RasterBandCombiner transformer. For example, combine the ...