arcpy.Describe().spatialReference

import arcpy

import os

from arcpy import env

import math

env.overwriteOutput = True

shp_sheet = arcpy.GetParameterAsText(0)
sr = arcpy.Describe(shp_sheet).spatialReference
arcpy.AddMessage("sr.type:"+sr.type)
arcpy.AddMessage("sr.datumName:"+sr.datumName)
arcpy.AddMessage("sr.name:"+sr.name)
arcpy.AddMessage("sr.PCSCode:"+str(sr.PCSCode))
arcpy.AddMessage("sr.PCSName:"+sr.PCSName)
arcpy.AddMessage("sr.projectionName:"+sr.projectionName)
arcpy.AddMessage("sr.projectionCode:"+str(sr.projectionCode))
arcpy.AddMessage("sr.GCSCode:"+str(sr.GCSCode))
arcpy.AddMessage("sr.GCSName:"+sr.GCSName)
arcpy.AddMessage("sr.spheroidName:"+sr.spheroidName)
arcpy.AddMessage("sr.type:"+sr.type)

投影信息如下:

sr.type:Projected
sr.datumName:
sr.name:Xian_1980_3_Degree_GK_Zone_35
sr.PCSCode:2359
sr.PCSName:Xian_1980_3_Degree_GK_Zone_35
sr.projectionName:Transverse_Mercator
sr.projectionCode:43006
sr.GCSCode:0
sr.GCSName:
sr.spheroidName:
sr.type:Projected

函数:

def batch_shape_proj(shape_path, save_path, reference_file):
    try:
        #if not os.path.exists(save_path):
            #os.mkdir(save_path)
        for file_list in os.listdir(shape_path):
            if file_list.endswith('.shp'):
                print(file_list)
                shape = shape_path + '/' + file_list  # 待投影文件
                outPath = save_path + "/" + file_list.split('.')[-2] + "_proj.shp"
                coordinate_system = arcpy.Describe("F:\\00义务劳动\\定义投影\\os\\hhh.shp").spatialReference
                print(coordinate_system.PCSCode)
                arcpy.Project_management(shape, outPath, )
    except arcpy.ExecuteError:
        print(arcpy.GetMessages())


def batch_raster_proj(raster_path, save_path, reference_file):
    try:
        if not os.path.exists(save_path):
            os.mkdir(save_path)
        for file_list in os.listdir(raster_path):
            if file_list.endswith('.tif'):
                raster = raster_path + '/' + file_list  # 待投影文件
                outPath = save_path + "/" + file_list.split('.')[-2] + "_proj.tif"
                coordinate_system = arcpy.Describe(reference_file).spatialReference
                arcpy.ProjectRaster_management(raster, outPath, coordinate_system, "BILINEAR", "", "", "#", "#")
    except arcpy.ExecuteError:
        print(arcpy.GetMessages())

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值