jpedder returning NoData

Discussion created by jpedder on Feb 25, 2013
Latest reply on Jan 27, 2014 by selfert
Been struggling with this for a couple of days now and could use a fresh set of eyes on the problem. I'm trying to get an elevation spot value for a DEM file. When I inspect any point with the Information Tool I get a pixel value of elevation. However when I try tp pull the value using I always get a NoData.

This is pretty generic code that was pulled form Google searches, it reports the X and Y correctly just not the pixel value.

Any help would be appreciated


class ToolClass10(object):
    """Implementation for MapSARElevation_addin.tool_1 (Tool)"""
    def __init__(self):
        self.enabled = True
        self.shape = "NONE" # Can set to "Line", "Circle" or "Rectangle" for interactive shape drawing and to activate the onLine/Polygon/Circle event sinks.
    def onMouseDown(self, x, y, button, shift):
    def onMouseDownMap(self, x, y, button, shift):
        mxd = arcpy.mapping.MapDocument("CURRENT")
        df = arcpy.mapping.ListDataFrames(mxd)[0]
        layers = arcpy.mapping.ListLayers(mxd, None, df)
        rasterlayer = None
        for layer in layers:
            if layer.isRasterLayer:
                rasterlayer = layer
        if rasterlayer:
            cellvalue =, "{} {}".format(x, y)).getOutput(0)
            pythonaddins.MessageBox("XY: {}, {}\nCell Value: {}".format(x, y, cellvalue), "Results")