Getting elevation for x,y when having multiple rasters

Discussion created by kuiperfoliage on Jan 4, 2013
Latest reply on Feb 17, 2014 by kuiperfoliage

I made a script to get the Z value for a list of terrains files at a specific X,Y, but the script can not be converted into a GPK because of the methods i'm using.

Does anybody have another good simple approach to do this, which can be packaged into a GPK ?

I will need to replace MosaicToNewRaster_management and GetCellValue_management, but i'm not sure how! I was thinking on using the Raster class and/or some NumPy approach, but can't figure out how to do it. Anybody have some leads on how to achieve this ?

import arcpy
from arcpy import env
from arcpy.sa import *

# Check out the ArcGIS Spatial Analyst extension license

arcpy.gp.overwriteOutput = 1

print "Start"

# original terrain data
terrainOne = r"C:\MyFolder\TerrainFiles\ned_25581390.flt";
terrainTwo = r"C:\MyFolder\TerrainFiles\ned_57214367.flt";

tempRasterFolder = r"C:\Myfolder\scratch.gdb"
tempRaster = "tempRaster"

arcpy.MosaicToNewRaster_management(terrainOne + ";" + terrainTwo, tempRasterFolder, tempRaster, number_of_bands=1, mosaic_method="LAST")

# location to get Elevation from
source = arcpy.Point( )
source.X = -87.6815094515746
source.Y =  41.811765962018300

# define string
sourceString = str(source.X) +  str(" ") + str(source.Y)
sourceElevationString = arcpy.GetCellValue_management(tempRasterFolder +"\\"+ tempRaster, sourceString)
#sourceElevationString = arcpy.GetCellValue_management(terrainOne, sourceString)

# get elevation
result = sourceElevationString.getOutput(0)

if result != 'NoData':
    source.Z = float(result)

    # print (converted meters to feet)
    print str(source.Z)
    print str(source.Z / 0.3048)
    print "value (x,y) not found on raster"