转载链接:http://blog.youkuaiyun.com/heyubingzju/article/details/5845136
作用:给指定目录下的栅格数据批量赋Spatial Reference
- # ---------------------------------------------------------------------------
- # define sr.py
- # Created on: 周六 三月 06 2010 11:18:20 上午
- # (generated by ArcGIS/ModelBuilder)
- # Usage: define sr <Input_Dataset_or_Feature_Class> <Coordinate_System>
- # ---------------------------------------------------------------------------
- # Import system modules
- import sys, string, os, arcgisscripting
- # Create the Geoprocessor object
- gp = arcgisscripting.create(9.3)
- # Load required toolboxes...
- gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
- # Script arguments...
- Input_Raster_Folder = gp.GetParameterAsText(0)
- Coordinate_System = gp.GetParameterAsText(1)
- # Process: Define Projection...
- gp.Workspace = Input_Raster_Folder
- tiffs =gp.ListRasters("*","TIF")
- for tiff in tiffs:
- try:
- #gp.defineprojection(tiff, Coordinate_System)
- gp.DefineProjection_management(tiff, Coordinate_System)
- gp.addwarning("Define raster dataset " + tiff + " spatial reference succeed!")
- except:
- gp.addwarning(gp.getmessage(2))