# coding=utf-8
# 3. 投影
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script
# The following inputs are layers or table views: "lspop2013"
import sys, os
import arcpy
from arcpy import *
import glob
# 设定输入、输出路径
input_path = r'G:\fa\01_rainfall_month'
output_path = r"G:\fa\01_rainfall_month\rainfall_month_prj"
# 创建文件夹
if os.path.exists(output_path)==False:
os.mkdir(output_path)
# 定义工作空间
arcpy.env.workspace = input_path
# 得到所有tif格式影像
rasterlist = arcpy.ListRasters("*", "tif")
# 定义投影
Coordinate_System="PROJCS['WGS_1984_UTM_Zone_49N',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',111.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]"
# 收集栅格数据
rasters = glob.glob(os.path.join(input_path, "*.tif"))
# 批量投影
for raster in rasters:
name = os.path.basename(raster).split(".")[0] + ".tif"
out_name = os.path.join(output_path, name)
print out_name
arcpy.ProjectRaster_management(raster, out_name, Coordinate_System, "NEAREST")
批量投影代码
最新推荐文章于 2024-07-30 17:23:09 发布