The clip tool will use a polygon boundary (clipping file) to clip features that are contained within it. The results of the process will be the creation of a new file for the selected region. In this example, multiple shapefiles will be clipped and each will be stored with a new name. This will be accomplished through three individual commands and will not use a looping statement. The format for the clip command is:
arcpy.Clip_analysis(input file, clipping file, output file) |
- Import arcpy
- Import environment from arcpy
- Defining the workspace which is a geodatabase.
- Creating a variable called county and defining the string content as Trimble, this is our county of interest. If the script is for a different county then the name would be replaced.
- All three clipping commands are the same, the first file to be clipped is the kyrivers file. The pathway is only the file name since the workspace had already been defined. The clipping boundary will be KY_Trimble, a polygon feature class file. The output file will be Trimble_rivers, which is based on the use of the variable and the information inside the quotations. The clipping file could have been defined as “KY_”+county.
- The output files are stored in the same geodatabase as the input file.