码迷,mamicode.com
首页 > 编程语言 > 详细

批量定义投影转换(python)

时间:2019-09-01 20:17:52      阅读:290      评论:0      收藏:0      [点我收藏+]

标签:module   desc   put   script   ext   parameter   manage   model   pen   

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)

标签:module   desc   put   script   ext   parameter   manage   model   pen   

原文地址:https://www.cnblogs.com/pumpkin-123/p/11443408.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!