批量定义投影转换(python)

1.打开ArcMap的python工具

2.输入

# ---------------------------------------------------------------------------
# ProjectionConversion.py
# Created on: 2019-09-1 
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import os
import arcpy
from arcpy import *

def huoqu(jieshou,lujing):
    print("getting tif file...")
    for dirpath,dirnames,filenames in os.walk(lujing):
        for filename in filenames:
            if  os.path.splitext(filename)[1] == '.tif':
                file1 = dirpath+'\\'+filename
                jieshou.append(file1)
    print("get "+str(len(jieshou))+" records")

tifz=[]
path="D:\\XinYi\\xinyiDOM\\XINYIDOM"
outputpath="G:\trans\After"
huoqu(tifz,path)
string1="PROJCS['WGS_1984_Transverse_Mercator',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',118.3333],PARAMETER['scale_factor',1.0],PARAMETER['latitude_of_origin',0.0],UNIT['Meter',1.0]]"
for tif in tifz:
    arcpy.DefineProjection_management(tif, string1)
# Process: Define Projection

    #print(str(i)+".define project:"+(str(tif)).split('\\')[-1])
    #outputtif=outputpath+"\\"+(str(tif)).split('\\')[-1]
# Process: Project Raster
    #print("Project Raster:"+(str(tif)).split('\\')[-1])
   # arcpy.ProjectRaster_management(tif,outputtif, string1)
    #i=i+1

猜你喜欢

转载自www.cnblogs.com/pumpkin-123/p/11443408.html