python在ArcGIS中的应用
读取栅格数据的脚点坐标、影响名、坐标系
import arcpyarcpy.env.workspace=”C:\Python27″
try:
descRaster=arcpy.Describe(“D:\\data3\\4026.0-540.0.tif”) #os.path.join(root,file)
ext=descRaster.extent
name1=descRaster.name
print(“XMin: %f” % (ext.XMin))
print(“XMax: %f” % (ext.XMax))
print(“YMin: %f” % (ext.YMin))
print(“YMax: %f” % (ext.YMax))
print”name,is,%s”%name1
sr=descRaster.SpatialReference
print(sr.name)
print(sr.type)
except Exception as e:
print(e.message)
批量投影
import arcpy
import os
fileDir=”E:”+os.sep+”571a”
for root,dirs,files in os.walk(fileDir):
print root,dirs
for filen in files:
if os.path.splitext(filen)[1]==”.tif”: #提取tif文件
file1=os.path.join(root,filen)
arcpy.ProjectRaster_management(file1, “E:\\5711a\\”+filen, “GEOGCS[‘GCS_WGS_1984’,DATUM[‘D_WGS_1984’,SPHEROID[‘WGS_1984’,6378137.0,298.257223563]],PRIMEM[‘Greenwich’,0.0],UNIT[‘Degree’,0.0174532925199433]]”, “NEAREST”, “3.99872097730881E-05 3.99872097730883E-05”, “”, “”, “PROJCS[‘WGS_1984_Web_Mercator_Auxiliary_Sphere’,GEOGCS[‘GCS_WGS_1984’,DATUM[‘D_WGS_1984’,SPHEROID[‘WGS_1984’,6378137.0,298.257223563]],PRIMEM[‘Greenwich’,0.0],UNIT[‘Degree’,0.0174532925199433]],PROJECTION[‘Mercator_Auxiliary_Sphere’],PARAMETER[‘False_Easting’,0.0],PARAMETER[‘False_Northing’,0.0],PARAMETER[‘Central_Meridian’,0.0],PARAMETER[‘Standard_Parallel_1’,0.0],PARAMETER[‘Auxiliary_Sphere_Type’,0.0],UNIT[‘Meter’,1.0]]”)
转载自:https://blog.csdn.net/u010624166/article/details/80139925