Power Of Phyton Scripting In ArcGIS ( Useful Codes)
Some Useful Phyton Codes For Batch Geoprocessing
Batch Clip Geoprocessing Tool
Batch Save Layer In MXD
Batch Clip Geoprocessing Tool
import arcpy
import os
# The workspace environment needs to be set before ListFeatureClasses
# to identify which workspace the list will be based on
arcpy.env.workspace = "c:/data"
out_workspace = "c:/data/results/"
clip_features = "c:/data/testarea/boundary.shp"
# Loop through a list of feature classes in the workspace
for fc in arcpy.ListFeatureClasses():
# Set the output name to be the same as the input name, and
# locate in the 'out_workspace' workspace
#
output = os.path.join(out_workspace, fc)
# Clip each input feature class in the list
#
arcpy.Clip_analysis(fc, clip_features, output, 0.1)
Batch Save Layer In MXD
# import Phyton Geoprocessing Module
import arcpy
# set up MXD location
mxd = arcpy.mapping.MapDocument("E:\PII_Aceh2014\PII_Aceh2014\PETA INFRASTRUKTUR INDONESIA\ALBUM PETA\A3\Kabupaten\ACEHTAMIANG_2014.mxd")
# Listing Layers in MXD
for lyr in arcpy.mapping.ListLayers(mxd):
# Layer Saving
lyr.saveAcopy(lyr.name + ".lyr")
Comments
Post a Comment