遥感生态遥感的学习笔记

基于Python的批量定义投影

2019-06-25  本文已影响6人  荔枝猪

需求

一些MODIS EVI数据需要转换为跟自己数据一致的投影。

定义坐标系信息

可以先定义一个Shpfile的投影信息,然后把它的.prj文件用记事本打开,记得修改里面的符号'

栅格图像的投影定义

import arcpy
# 设置工作空间
arcpy.env.workspace="E:\\GPP\\test2"
# 得到所有tif格式影像
rasterlist = arcpy.ListRasters("*", "tif")   
#定义坐标系统
Coordinate_System = "PROJCS['WGS_1984_Albers',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Albers'],PARAMETER['false_easting',0.0],PARAMETER['false_northing',0.0],PARAMETER['central_meridian',105.0],PARAMETER['standard_parallel_1',25.0],PARAMETER['standard_parallel_2',47.0],PARAMETER['latitude_of_origin',0.0],UNIT['Meter',1.0]]"
#循环
for raster in rasterlist:
    print str(raster)
    arcpy.DefineProjection_management(raster, Coordinate_System)
print("OK!")   #运行完毕,显示OK。

要素类的投影定义

import arcpy
# 设置工作空间
arcpy.env.workspace="E:\\GPP\\test2"
# 得到所有要素
featurelist = arcpy.ListFeatureClasses()  
# define coordinate system
Coordinate_System = "PROJCS['WGS_1984_Albers',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Albers'],PARAMETER['false_easting',0.0],PARAMETER['false_northing',0.0],PARAMETER['central_meridian',105.0],PARAMETER['standard_parallel_1',25.0],PARAMETER['standard_parallel_2',47.0],PARAMETER['latitude_of_origin',0.0],UNIT['Meter',1.0]]"
#循环
for ft in featurelist:
    print str(ft)
    arcpy.DefineProjection_management(ft, Coordinate_System)
print("OK!")
上一篇下一篇

猜你喜欢

热点阅读