批量定义投影转换(python)

Posted pumpkin-123

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批量定义投影转换(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

 

以上是关于批量定义投影转换(python)的主要内容,如果未能解决你的问题,请参考以下文章

GlobeLand30全球数据处理教程(批量投影转换无效值处理拼接)

GlobeLand30全球数据处理教程(批量投影转换无效值处理拼接)

GlobeLand30全球数据处理教程(批量投影转换无效值处理拼接)

ArcGIS风暴GlobeLand30全球数据处理教程(批量投影转换无效值处理拼接)

ArcGIS风暴GlobeLand30全球数据处理教程(批量投影转换无效值处理拼接)

Arcgis之栅格数据转投影转换(84转2000)