???? For the cropping of a raster, we usually crop it with crop (data management-raster-raster processing) or by masking (spatial analysis-extraction analysis), which is typically a feature layer or shape file. If you want to do batch processing, you can use the Bulk processing tool in toolbox. However, sometimes the crop vector feature that we select is not a feature layer, but rather a feature in a feature layer, such as trimming a raster image by a standard map, the previous practice is to export the features one at a time and then batch processing. Quick Export method: ArcGIS Splits files by field attributes.
???? Now, you can use Python script to crop in bulk, and find a great God's original code on the Internet to learn:
- #-*-Encoding:utf-8-*-
- ?
- # Tool Name: Traverse feature clipping raster
- # Source Name:extractByMask.py
- # Version:arcgis 10.1
- # Author:giscloud
- # CREATED:2012/11/1
- ?
- Import arcpy
- Import String
- From ARCPY.SA Import *
- ?
- Try:
- ???? Raster = arcpy. Getparameterastext (0) #要裁剪的栅格
- ???? Clip_feat = arcpy. Getparameterastext (1) #裁剪要素类
- ???? field = arcpy. Getparameterastext (2) #命名字段
- ???? Outworkspace = arcpy. Getparameterastext (3) #命名字段裁剪后输出目录
- ?
- ???? for Row in arcpy. Searchcursor (clip_feat):
- ???????? Mask=row.getvalue ("Shape")
- ???????? outpath=outworkspace+ "\ \" +str (row.getvalue (field))
- ???????? Outextractbymask = Extractbymask (raster,mask)
- ???????? Outextractbymask.save (Outpath)
- ?
- Except arcpy. Executeerror:
- ???? Print arcpy. Getmessages ()
???? Export script to Toolbox, execute Error: unicodeencodeerror: ' ASCII ' codec can ' t encode characters in position 32-34:ordinal not in range (128) Q The Ulipad compiler is used.
???? Looks like a coding problem. Solution: Add code to set default edits at the beginning
- Import Sys
- Reload (SYS)
- Sys.setdefaultencoding ("utf-8")
Able to achieve partial trimming, but the last one out of the question, see the message output of the file name of how many more a period?
???? There is no problem viewing the property sheet. The output field "Beichuan Qiang Autonomous County" changed to "Beichuan Qiang autonomous" can be correctly exported, if changed to "Beichuan Qiang autonomous Beichuan Qiang autonomous", and reported the same mistake. The description should be an issue with the output name length.
Also, there is a problem with the different raster boundaries of the output, and if you avoid this, you can only change system variables and output smaller cell sizes.
Reference: http://bbs.esrichina-bj.cn/ESRI/viewthread.php?tid=121642
???? http://blog.sina.com.cn/s/blog_64a3795a01018vyp.html
?
Crop a raster in bulk using a Python script