# ---------------------------------------------------------------------------
# MeteorologicalImageLoad.py
# Created on: 2014-01-24 08:33:03.00000
# Created by SmartMap
# Usage: MeteorologicalImageLoad <analyzeType> <analyzeResult>
# Description:
# ---------------------------------------------------------------------------
import arcpy
import shutil
import os,sys
arcpy.env.overwriteOutput = True
projectNameSatelliteImage = ‘GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433],AUTHORITY["EPSG",4326]]‘
projectNameWaterReport = ‘PROJCS["Asia_North_Equidistant_Conic",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Equidistant_Conic"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",95.0],PARAMETER["Standard_Parallel_1",15.0],PARAMETER["Standard_Parallel_2",65.0],PARAMETER["Latitude_Of_Origin",30.0],UNIT["Meter",1.0],AUTHORITY["ESRI",102026]]‘
projectNameWeatherRadar = ‘PROJCS["Asia_Lambert_Conformal_Conic",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",105.0],PARAMETER["Standard_Parallel_1",30.0],PARAMETER["Standard_Parallel_2",62.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["ESRI",102012]]‘
analyzeResult = "%scratchworkspace%\\analyzeResult.img"
# Script arguments
analyzeType = arcpy.GetParameterAsText(0)
if analyzeType == ‘#‘ or not analyzeType:
analyzeType = "SatelliteImage"
imageDirectory = "D:\\data\\SpatialData\\sourceDir\\" + analyzeType
copyTargetPath = "D:\\data\\SpatialData\\targetDir\\default" + analyzeType + ".jpg"
inputLinkFile = "D:\\data\\SpatialData\\targetDir\\" + analyzeType + "Tic.txt"
lastTime = 0
lastFilePath = "#"
if imageDirectory and imageDirectory != ‘#‘:
fileList = os.listdir(imageDirectory) #列出目录下的所有文件和目录
for line in fileList:
filepath = os.path.join(imageDirectory,line)
if os.path.isfile(filepath):
# os.stat(filepath).st_ctime
lastModifyTime = os.path.getctime(filepath)
if lastModifyTime > lastTime :
lastTime = lastModifyTime
lastFilePath = filepath
if lastFilePath == "#":
lastFilePath = "D:\\data\\SpatialData\\default" + analyzeType + ".jpg"
shutil.copy(lastFilePath, copyTargetPath)
# Process: Register Raster
arcpy.RegisterRaster_management(copyTargetPath, "REGISTER", "", inputLinkFile, "POLYORDER1", "")
# Process: Copy Raster
arcpy.CopyRaster_management(copyTargetPath, analyzeResult, "", "", "256", "NONE", "NONE", "", "NONE", "NONE")
# Process: 定义投影
if analyzeType == ‘SatelliteImage‘:
projectName = projectNameSatelliteImage
elif analyzeType == ‘WeatherRadar‘:
projectName = projectNameWeatherRadar
elif analyzeType == ‘WaterReport‘:
projectName = projectNameWaterReport
else:
projectName = projectNameSatelliteImage
arcpy.DefineProjection_management(analyzeResult, projectName)
arcpy.SetParameterAsText(1, analyzeResult)