python tif栅格数据投影转换

python 2.7下运行

import arcpy
from arcpy import env

# 设置工作空间
env.workspace = r"H:\data"

# 获取所有tif文件的路径
rasters = arcpy.ListRasters("*", "TIF")

# 设置投影坐标系
out_coordinate_system = arcpy.SpatialReference("CGCS_2000")
# out_coordinate_system = arcpy.SpatialReference("WGS 1984 UTM Zone 11N")

# 循环处理每个tif文件
for raster in rasters:
    # 构建输出路径和文件名
    out_raster = arcpy.Describe(raster).baseName + "_projected.tif"
    out_path = r"H:\course\RSwork\1yearr\ndvi\0ori\5py\ndvi\newproj"
    out_raster_path = out_path + "\\" + out_raster

    # 投影转换
    arcpy.ProjectRaster_management(raster, out_raster_path, out_coordinate_system)

你可能感兴趣的:(Python,python,开发语言)